Creating an infinite loop until an event occurs?
8 ビュー (過去 30 日間)
古いコメントを表示
I am trying to make a loop until a certain event happens. In my first drafts I simply let it run for a large number of steps. However, now that I am adding a few extra steps in between, and want it to stop, it is no longer viable. Before I could run
N=100 for t=1:N (calculations) End
Which would do the loop 100 times. However, now I want it to continue forever until a certain event occurs. So now I am getting to:
N=10000 for t=1:N (calculations)
if (calculations) End % and finish here completely and do not engage in any more loops
Else (more calculations) End % and this should repeat back to the ‘for’ statement
Is there any way I can have this loop continuing, and block it in the middle after a certain event? Otherwise, is there another way of doing it?
0 件のコメント
採用された回答
Stephen
2012 年 6 月 26 日
go = true;
while go
step1
step2
step3
if step3==stopcriteria
go=false
end
end
2 件のコメント
Walter Roberson
2012 年 6 月 26 日
編集済み: Walter Roberson
2019 年 7 月 26 日
Or
while true
step1
step2
step3
if step3==stopcriteria; break; end
end
その他の回答 (1 件)
Erencem Özbey
2018 年 7 月 12 日
what is step1 step2 step 3
1 件のコメント
N/A
2019 年 7 月 25 日
That just represents various lines of code. like what you want to do while in the "while true" loop
参考
カテゴリ
Help Center および File Exchange で Get Started with MuPAD についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!