how to give end condition to for loop
Afficher commentaires plus anciens
for e = (-246200:-246100)
for f = 224169
e
f
h = ((e*def)+f)
if h==138010
return;
end
end
end
1 commentaire
Rik
le 3 Mar 2019
And your question is?
There are multiple things that I would have written differently, but depending on the context this code should work.
Réponse acceptée
Plus de réponses (1)
Sheng Chen
le 3 Mar 2019
You already terminate your code by "return" if h equals 138010.
I assume you are asking how to terminate the inner for loop:
for f = 224169
....
end
You can put a "break" in this for loop: Terminate execution of for or while loop
for e = (-246200:-246100)
for f = 224169
e
f
h = ((e*def)+f)
if h==138010
break;
end
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!