0

I have two lines where ii should increment 1:12

1 2 3 4 5 6 7 8 9 10 11 12

for ii=1:6
    ii %line1
    ii+1 %line2
end

Instead I get ii 1 2 2 3 3 4 4 5 5 6 6 7

Ps: I need to use two lines in the for loop due to functions being called from these lines and filenames are created based on ii variable

1
  • 1
    As far as I know, you can't modify a loop variable inside its own loop in MATLAB. You could try using for ii=1:2:12 instead. Commented Mar 4, 2015 at 23:23

1 Answer 1

1

If you really need two lines, try:

for ii=1:6
  ii*2-1  
  ii*2    
end
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.