MATLAB: How to get uicontrol value inside a callback function

callbackgui

Hi, I have a have written a function which has several callback functions. My function acts on a figure. I have added a uicontrol button to my figure and this is where my problem starts.
I would like to get the value of the GUIbutton state while I am still inside another callback function.
%==another callback function===
button1 = uicontrol('Style','pushbutton', 'Value', f,'pos',...
[20 10 10 10],'string','text_here');
state=get(handles.button1, 'Value');
if state==1;%button is clicked
%do something
else
%do something else
end
%===another callback function====
this doesnt work, because the class handles is undefined, but unfortunately I am unable to understand how to fix it.

Best Answer

Functions cannot have callbacks. Objects (especially graphic objects) can have callbacks.