How to stop a for loop by press a button APP designer ?

14 views (last 30 days)
Hi Everyone,
Do you know how to stop a for loop by press a button in APP designer ?
I do a research but don't find any solution yet
Thanks !

Accepted Answer

CAM on 16 Aug 2022
Make the Stop button a toggle button.
Within the FOR loop, check the status of the Stop button. If it is toggled-on, then break out of the FOR loop.
After the FOR loop, toggle-off the Stop button.
[Please note that this is untested code]
for a = 1:loopCount
% << your main code >>
if app.tglStop.Value == 1
end % a
app.tglStop.Value = 0;
Hope this helps.

More Answers (0)


Find more on Develop Apps Using App Designer 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!