MATLAB: GUI Newbie

callbackguipush buttonuicontrol

I'm still a newbie when it comes to programming buttons in MatLab. I need to be able to add a button to a figure that acts as a start/stop button. I was able to get the button to appear on the figure, but I'm not sure how to handle the callback. Can someone help send me in the right direction?
Here is the code I have to format the button:
uicontrol('Style', 'pushbutton', 'String', ' Start/Stop ',...
'Position', [15 15 100 50],'FontSize',10,'FontWeight',...
'bold','Callback', 'cla');
Overall this is what I want to accomplish:
while(The button is depressed)
execute code
end
Thank you!

Best Answer

Assign the output of uicontrol() to a handle. Save the handle somewhere. Then in the routine that needs to check the state of the button, get() the 'Value' property of the button: 0 will indicate it is not pressed and 1 will indicate that it is pressed.