for loop start from first operation if df=1?
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
For a=1:20
Df=0;
If condition
Operation(a);
Condition reset;
Df=df+1;
End
If df==1
Repeat for loop again how to do it
End
0 comentarios
Respuestas (1)
Geoff Hayes
el 14 de Jul. de 2015
Arunachalam - I think that you may be able to repeat the above if you use a while loop. Something like
a = 1;
while a <= 20
if condition
Operation(a);
% Condition reset;
a = 1;
else
a = a + 1;
end
end
Not sure if the above is what you have intended but look how we just use a and not the Df to continue iterating or to restart the loop if some condition is met.
Note that the above code is dangerous as you could get stuck in an infinite loop. You may want to decide how many reset of a to one you should allow before terminating the while loop.
0 comentarios
Ver también
Categorías
Más información sobre Loops and Conditional Statements en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!