MATLAB app while loop in button

조회 수: 28 (최근 30일)
lital levy
lital levy 2022년 9월 5일
답변: Abolfazl Chaman Motlagh 2022년 9월 5일
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
while pausebutton.Value==1
end
but the program just get stuck in the loop..
it worked when i wrote-
for pausebutton.Value==1
pause(6);
end
but i need it to be a while loop so i can control manually when it will resumed.
any ideas?

답변 (1개)

Abolfazl Chaman Motlagh
Abolfazl Chaman Motlagh 2022년 9월 5일
one simple altenative i can give is use a property in your app. for example add this to properties:
properties (Access = public)
flag
when you want to start the loop make shore the value is 1 (or True) and in your while loop use this :
while app.flag
%%
end
in pausebutton pushed function use this :
function pausebuttonPushed(app, event)
app.flag = 0;
end
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:
while app.flag
%%
drawnow update;
end

카테고리

Help CenterFile Exchange에서 Develop Apps Using App Designer에 대해 자세히 알아보기

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by