How to make a for loop jump multiple iterations, if a condition happens?
이전 댓글 표시
I have to create a code that reads columns of an excel document, then it has to choose between three options. I called them option -1, option 0 and option 1. If -1 or 1 are choosen, then the code needs to jump six rows of the excel document. For example, if while reading row 4, it chooses 1, then the next row it should read should be 10. I tried to do something like this:
for r = 1:row %Reads the row of the excel file
if genes(r) == -1
%Does something
r = r+6 %r is now r+6
elseif genes(p,r) == 0
%Does Something
elseif genes(p,r) == 1
r = r+6 %r is now r+6
end
end
But in the next iteration the r is always the next number, and not r+6.
Can someone help.
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Matrix Indexing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!