|
Hello!
I have a checkbox in a gui with the following code:
------------------------------------------------------------------------------------
function checkbox1_Callback(hObject,eventdata,handles)
x = get (handles.checkbox1,'Value');
cd(handles.SomeDirectory)
load(file)
if x == 1
func1(variable1,'enable',handles.checkbox1);
elseif x == 0
func1(variable1,'disable',handles.checkbox1);
end
guidata(hObject,handles);
-----------------------------------------------------------------------------------
Now, the function "func 1" looks like this:
-----------------------------------------------------------------------------------
function func1 (variable1,toggle,handle)
switch toogle
case 'enable'
fig = imagesc(variable1);
set(fig,'Alphadata', ~isnan(variable1));
set(handle,'UserData',fig);
case 'disable'
delete(get(handle,'Userdata'));
end
------------------------------------------------------------------------------------
What the code does is that when I check the checkbox something is plotted in the gui's axes. When the checkbox is unchecked the plotted something is removed.
Toggleing between the checked and unchecked works fine until you speed up your clicking, Then my gui crashes, or in other words the gui gets reinitiated with all the fields (fields selected and edited by the user during gui run time) set to default.
So if I toggle to fast (i.e. doubble clicking) on the checkbox the gui crashes as mentioned above.
I get this error messages:
??? Error using ==> guidata at 89
H must be the handle to a figure or figure descent.
Error in ==> myprogram1>checkbox1_Callback at 804
guidata(hObject,handles);
I can´t figure it out what´s the problem that causes the crash. It works fine until you start speeding up your toggleing. Is there anyone matlab guru out there, that might know the solution to this problem or how to approach it?
Best regards
Theodor
|