MATLAB app while loop in button
15 views (last 30 days)
Show older comments
lital levy on 5 Sep 2022
Answered: Abolfazl Chaman Motlagh on 5 Sep 2022
hello, i built an routine in the app designer that starts in a push of a button and i want to create a paues toggle-button for it, i tried to write
but the program just get stuck in the loop..
it worked when i wrote-
but i need it to be a while loop so i can control manually when it will resumed.
Abolfazl Chaman Motlagh on 5 Sep 2022
one simple altenative i can give is use a property in your app. for example add this to properties:
properties (Access = public)
when you want to start the loop make shore the value is 1 (or True) and in your while loop use this :
in pausebutton pushed function use this :
function pausebuttonPushed(app, event)
app.flag = 0;
that will do it.
if you want the press buttom command rapidly apply to loop and pause it (skip other updates in query of app) use this in the while loop:
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!