Returning Back to some Previous Loop if a separate condition is met
古いコメントを表示
What is the most efficient way for me to accomplish the following:
I want to loop some function while a condition is true.
while (something is true)
do this
end
Once that something is no longer true, essentially what I want to do is find a way to go back to that "while loop" if a separate condition is met. For instance:
while (something is true)
do this
end
input()
if (if that input is a certain value)
GO BACK to the previous loop
end
Is there any way to get 'back' to the other loop? Essentially I wan't to ask "are you sure you want to stop doing that while loop?" and if not, go back to the while loop again.
Thanks
回答 (1 件)
Walter Roberson
2011 年 9 月 26 日
Nope, no way of doing that. So don't. Instead,
while true
while (something is true)
do this
end
yesno = input()
if yesno ~= the certain value
break;
end
end
カテゴリ
ヘルプ センター および File Exchange で Startup and Shutdown についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!