Filter löschen
Filter löschen

FOR loop skipping to a particular iteration

3 Ansichten (letzte 30 Tage)
sairohith mudduluru
sairohith mudduluru am 19 Feb. 2018
Kommentiert: Walter Roberson am 19 Feb. 2018
for i=2:1:(length(time_c)-1)
if wheelpower_c(i)>= 0
propulsionpower(i)=propulsionpower(i-1)+wheelpower_c(i);
Regenpower(i)=Regenpower(i-1);
Brakeloss(i)=Brakeloss(i-1);
I(i)=(Voc-sqrt((Voc^2)-(4*R.*batterypower_city(i))))/(2*R);
Soc(i)=Soc(i-1)-(I(i)*DT/battery_capacity_C);
V(i)=Voc-R*I(i);
this a part of my for loop and i wanna check whether my conditions hold at i=576 can i skip to that particular iteration? Thank you
length(time_c)=1374
  3 Kommentare
sairohith mudduluru
sairohith mudduluru am 19 Feb. 2018
its a dependency loop and i wanna run the loop automaticallyfor the first 575 values and debugg the 576th iteration can i do that?
Walter Roberson
Walter Roberson am 19 Feb. 2018
If you need to debug 576 then use the conditional breakpoint method.

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 19 Feb. 2018
No. The closest you can get is to modify your
for i=2:1:(length(time_c)-1)
to
for i = 576
You should also consider putting in a conditional breakpoint. Go into the editor and find the line "if wheelpower_c(i)>= 0" and look on the left side of the line, to the narrow strip between the line number and the code edit area. Right click on the small dash there, and select conditional breakpoint. A box will pop up asking you for the condition: enter
if i == 576
and accept that. Then run your code. It will not skip to 576: it will execute all previous iterations. But then when 576 does come around, it will stop with a breakpoint, at which point you can examine variables and use the "Step" and "Step In" buttons to advance the code.

Weitere Antworten (0)

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