MATLAB: Stop a while loop using a GUI

function handleguihandlesMATLAB

Hey everyone,
I need to stop a while loop using a 'Stop' button in a GUI and i was wondering what are the best ways of doing that.

Best Answer

A short example:
h = uicontrol('Style', 'PuchButton', 'String', 'Stop', ...
'Callback', 'delete(gcbo)');
while ishandle(h)
disp(datestr(now, 0));
pause(0.25);
end
Check out the famous 41 GUI example.