using subplot(m,n,p,ax) in a loop
Show older comments
Hi, If I have this plot
x = linspace(1,10);
y = sin(x);
plot(x,y)
title('Sine Plot')
And want to assign it to a subplot with the same axes, I will do
ax1 = gca;
subplot(2,1,1,ax1)
But now if I want a new plot at subplot(2,1,2) with the same axes, I can’t do
ax1 = gca;
subplot(2,1,2,ax1)
because it deletes the previous plot. How can I keep both plots?
Cheers, p.
Accepted Answer
More Answers (1)
Salaheddin Hosseinzadeh
on 11 Jun 2015
Just put figure outside the loop.
If you want to change each axis or maybe axes properties, use xlim ylim in your for loop you can only have
for i = 1:N
subplot(1,N);
plot(data);
xlim([-x,x]);
ylim([-y,y]);
end
something like this
1 Comment
Payal Bal
on 13 Jun 2015
Categories
Find more on Image Arithmetic 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!