0

I want to plot 2 graphs in each loop so that they will appear in two separate figures, with consecutive number order. I mean: first looping: figure 1, figure 2, second looping: figure 3, figure 4 and so on. How do I achieve that? I tried to make the code as follows,

for i = 1:3 
figure(i)
plot something

figure(i+1)
plot something else

but I get the order as : figure(1), figure(2), figure(2), figure(3), figure(3), figure(4) !!

2 Answers 2

2

Here's what you need to do:

for k=1:3 % don't use i as a variable
    figure(2*k-1)
    % Plot some stuff
    figure(2*k)
    % Plot some more stuff
end
Sign up to request clarification or add additional context in comments.

Comments

1

Your code should be this:

for i = 1:3 
 figure(2*i-1)
 plot something

 figure(2*i)
 plot something else
end

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.