Abort button on MATLAB GUIs
2 views (last 30 days)
Show older comments
I've seen a lot of posts on this subject, but none of them answer the problem I'm having. I've got a GUI that controls a rotating platform used for scanning antennae over different angles. It steps through a series of angles, taking data at each step. I'm trying to get an abort button to work by setting a global handle's (to the abort button) value to 1 when the button is pressed, then checking this value via get(h,'Value') in the scan loop before each step and breaking the loop if the value is 1.
The problem I'm having is that the scan is taking priority over the abort button, so that the GUI doesn't aknowledge the abort being pressed until the full scan is done. This means that the value doesn't change to 1, so the abort never happens. Is there a way that I can make the scan part interruptable? Thank you!
0 Comments
Answers (1)
Image Analyst
on 23 Jan 2014
I've noticed that too. What I do is to have a checkbox that says "Finish Now". Then, in your loop, check the value and exit if it's checked.
set(handles.chkFinishNow, 'visible', 'on');
while true
% Your code
if get(handles.chkFinishNow, 'value')
break;
end
end
set(handles.chkFinishNow, 'visible', 'off');
3 Comments
Image Analyst
on 23 Jan 2014
It might not update if it's in a really computationally intensive loop. Put a "drawnow" command after anytime you want to force the display to update.
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!