How to continue while loop after a break?
2 ビュー (過去 30 日間)
古いコメントを表示
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 件)
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
2021 年 6 月 23 日
This java sleep function is very accurate and can be called directly into MATLAB
参考
カテゴリ
Help Center および File Exchange で Loops and Conditional Statements についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!