필터 지우기
필터 지우기

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

조회 수: 4 (최근 30일)
Mr M.
Mr M. 2018년 7월 3일
편집: Walter Roberson 2018년 7월 4일
for i = 1:10
if i == 3
i = i+2;
end
end

답변 (2개)

Tejas Jayashankar
Tejas Jayashankar 2018년 7월 3일
Hi,
Check out the following answer for a similar question:
Let me know if this helps.

Jan
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

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by