Duplicate subplots within loop
Show older comments
Hi everyone,
i would like to duplicate plots in 2 subplots with different axis settings within a loop. What i want to do is to duplicate the plot from the first subplot and then change the axis properties. If i start with something like this:
x = linspace(-2*pi,2*pi,100);
figure
for i=1:100
y = sin(x+i);
subplot(2,1,1)
hCurve = plot(x,y,'r');
drawnow
subplot(2,1,2)
hSub2 = subplot(2,1,2);
copyobj(hCurve,hSub2);
drawnow
end
the top subplot gets refreshed every iteration, while for the bottom subplot the hold property seems to be on. Changing this property via axis handle doesn't seem to work. I suspect the copyobj function is the key, but how do i achieve the same behavior on both plots?
Thank you very much!
Accepted Answer
More Answers (0)
Categories
Find more on Subplots 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!