How to continue while loop after a break?

조회 수: 7 (최근 30일)
MSolano
MSolano 2021년 6월 23일
댓글: MSolano 2021년 6월 23일
I created an animation in app designer with a while loop, I want to be able to pause it and also resume it from the point it was stopped.
I have a set of toggle buttons: pause and resume, I can make it stop when I push pause but I can't make it continue with resume button after the break happens in the loop, I would really appreciate any advice on what I'm doing wrong
while time < 50
% Animation
drawnow
g = get(app.PauseButton,'Value');
h = get(app.ResumeButton,'Value');
if isequal(g, 1)
break
elseif isequal(h, 1)
continue
end
end
  댓글 수: 1
KSSV
KSSV 2021년 6월 23일
If you use break, loop will be exited.

댓글을 달려면 로그인하십시오.

답변 (1개)

Kishan Dhakan
Kishan Dhakan 2021년 6월 23일
편집: Kishan Dhakan 2021년 6월 23일
Instead of using break, why don't you try using the sleep command with a parameter of 0.3 to see how the animation looks. That should resolve this.
java.lang.Thread.sleep(duration*1000) % in sec!
  댓글 수: 2
Kishan Dhakan
Kishan Dhakan 2021년 6월 23일
This java sleep function is very accurate and can be called directly into MATLAB
MSolano
MSolano 2021년 6월 23일
Hi Krishan, thanks for taking the time to answer, I replaced the break for the java.lang.Thread.sleep(duration*1000) and I got a message: No method 'java.lang.Thread.sleep' with matching signature found. Is there a sleep command like you mentioned for matlab? I tried with uiwait and uiresume but I'm working on UIAxes and it says "input argument must be of type figure"

댓글을 달려면 로그인하십시오.

카테고리

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