Please help in convergence of the array
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Triveni
am 4 Aug. 2016
Kommentiert: Triveni
am 4 Aug. 2016
for l = 1:6
c11 (l)=opt11{l};
end
output = c11 =
Columns 1 through 5
89.0475 98.7932 98.7932 98.7932 98.7932
Column 6
98.7932
I want to break the loop "l" in program if c11(i+1)<=c11(i). please help me.
0 Kommentare
Akzeptierte Antwort
Guillaume
am 4 Aug. 2016
Bearbeitet: Guillaume
am 4 Aug. 2016
Well, you already nearly wrote the answer yourself!
for ...
... do something
if condition
break; %stop the loop
end
end
So, in your case, probably:
for l = 1:6
c11(l) = opt11{l}
if l>1 && c11(l) <= c11(l-1)
break;
end
end
Of course, the above could be just written without the loop:
c11 = cell2mat(opt11(1:6));
c11 = c11(logical(cumprod(diff(c11) > 0)));
3 Kommentare
Stephen23
am 4 Aug. 2016
@Triveni: it sounds like you are really trying achieve some task which you have not told us about. Rather than getting us to fix some broken code, it would be better if you actually described what you are trying to achieve:
Weitere Antworten (0)
Siehe auch
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!