if in for loop

1 Ansicht (letzte 30 Tage)
atarli
atarli am 22 Okt. 2013
Beantwortet: Walter Roberson am 22 Okt. 2013
i want to control my for loop with if, for example:
for i=1:1:10
a(i)=...
a(i+1)=...
now i want to here make a comparision between a(i) and a(i+1) then if a(i+1)<a(i) i will be next value in for loop
But if a(i+1)>a(i) program should exit from the for loop. How can I do that?

Antworten (1)

Walter Roberson
Walter Roberson am 22 Okt. 2013
if a(i+1) > a(i)
break
end

Kategorien

Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by