How to make a for loop jump multiple iterations, if a condition happens?
Show older comments
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.
Accepted Answer
More Answers (0)
Categories
Find more on Matrix Indexing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!