Effacer les filtres
Effacer les filtres

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

22 vues (au cours des 30 derniers jours)
Jenifer NG
Jenifer NG le 16 Août 2022
Commenté : Jenifer NG le 17 Août 2022
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 !

Réponse acceptée

CAM
CAM le 16 Août 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
break
end
end % a
app.tglStop.Value = 0;
Hope this helps.

Plus de réponses (0)

Catégories

En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange

Produits


Version

R2022a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by