Reputation: 177
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)
!!
Upvotes: 0
Views: 106
Reputation: 29064
Your code should be this:
for i = 1:3
figure(2*i-1)
plot something
figure(2*i)
plot something else
end
Upvotes: 1
Reputation: 13876
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
Upvotes: 2