Borrar filtros
Borrar filtros

FOR loop skipping to a particular iteration

3 visualizaciones (últimos 30 días)
sairohith mudduluru
sairohith mudduluru el 19 de Feb. de 2018
Comentada: Walter Roberson el 19 de Feb. de 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 comentarios
sairohith mudduluru
sairohith mudduluru el 19 de Feb. de 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 el 19 de Feb. de 2018
If you need to debug 576 then use the conditional breakpoint method.

Iniciar sesión para comentar.

Respuesta aceptada

Walter Roberson
Walter Roberson el 19 de Feb. de 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.

Más respuestas (0)

Categorías

Más información sobre Loops and Conditional Statements en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by