How to stop a for loop by press a button APP designer ?
16 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Jenifer NG
el 16 de Ag. de 2022
Comentada: Jenifer NG
el 17 de Ag. de 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
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1099055/image.png)
Thanks !
0 comentarios
Respuesta aceptada
CAM
el 16 de Ag. de 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.
Más respuestas (0)
Ver también
Categorías
Más información sobre Develop Apps Using App Designer en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!