Is it possible to change the running index in a for cycle?

Risposte (2)

This does not work in a for loop, but it works with while:
i = 1;
while i <= 10
disp(i)
if i == 3
i = i+2;
end
i = i + 1;
end
Alternatively:
for i = [1:3, 5:10]
disp(i)
end

Categorie

Scopri di più su Loops and Conditional Statements in Centro assistenza e File Exchange

Tag

Richiesto:

il 3 Lug 2018

Community Treasure Hunt

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

Start Hunting!

Translated by