My 'while' loop no longer recognizes stop.
Show older comments
This used to work:
while ( strcmp(get(hObject,'String'),'Stop') )
stuff
end
This while loop for running an animation is in the callback for a GUI button that changes between 'Start' and 'Stop' when pressed.
It used to be that the button was enabled during the execution of the 'while' loop, such that pushing the button again would stop the animation.
In R2016b, that no longer seems to be the case.
==> Is there a way for GUI buttons to be enabled during a callback 'while' loop, or is there another kind of loop that can be aware of changes so that it can be interrupted?
5 Comments
Rik
on 2 Nov 2017
I am using a very similar trick to interrupt a long looped calculation and I have no problems on R2017b or R2012b. So are you sure nothing else changed? Have you tried what output that get is giving you when you don't use a loop?
David Christhilf
on 2 Nov 2017
Rik
on 2 Nov 2017
It is very unlikely this works in R2012b and R2017b, but not R2016b.
I did use a callback to set a value. You can even store a boolean in the struct you save in guidata (don't forget to reload your guidata every loop iteration if you go down that path).
David Christhilf
on 2 Nov 2017
Rik
on 2 Nov 2017
You are storing handles before reloading it, which will overwrite any changes made in a callback.
Answers (1)
Walter Roberson
on 2 Nov 2017
0 votes
You do not appear to have a drawnow() or pause() or uiwait() or waitfor() or figure() to allow the graphics queue to be flushed to permit the interrupt of clicking the button to be serviced.
Categories
Find more on Animation in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!