Use guidata, which calls setappdata and getappdata internally:
function pushbutton1_Callback(hObject, eventdata, handles)
handles = guidata(hObject);
handles.counter = 1;
guidata(hObject, handles);
function pushbutton5_Callback(hObject, eventdata, handles)
handles = guidata(hObject);
switch handles.counter
case 1
case 2
case 3
case 4
otherwise
error('Programming error')
end
end
Best Answer