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!