Returning Back to some Previous Loop if a separate condition is met
Afficher commentaires plus anciens
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
Réponses (1)
Walter Roberson
le 26 Sep 2011
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
Catégories
En savoir plus sur Loops and Conditional Statements dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!