Is it possible to change the running index in a for cycle?
1 回表示 (過去 30 日間)
古いコメントを表示
for i = 1:10
if i == 3
i = i+2;
end
end
0 件のコメント
回答 (2 件)
Tejas Jayashankar
2018 年 7 月 3 日
Hi,
Check out the following answer for a similar question:
Let me know if this helps.
0 件のコメント
Jan
2018 年 7 月 4 日
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
0 件のコメント
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!