How to show two figures of dynamic plots next to each other?

23 次查看(过去 30 天)
Dear all,
I have two for-loops. Each loop generates a data which I am plotting (inside the loop) so as I can see the plot dynamically changing. Right now I process one plot which will open in one figure and once it is finished I close it and go to the next for-loop and see the second dynamic plot.
I want to be able to see these two dynamic plots at the same time. I tried to use subplot(2,1,1) in the first for-loop and subplot(2,2,1) in the second for-loop but things are not working well.
Is there someway to do it correctly?
Any help will be appreciated.
Meshoo

采纳的回答

Thorsten
Thorsten 2014-10-8
Use drawnow, pause, and specify the axis as in the following example
for i = 1:2
subplot(1,2,1)
axis([0 20 0 20])
plot(i, i, '.')
drawnow
hold on
subplot(1,2,2)
axis([0 20 0 400])
plot(i, i^2, 'o')
drawnow
hold on
pause(0.1)
end
  3 个评论
Felipe
Felipe 2014-12-4
Hi Meshooo,
Which modifications did you use to make it work? I'm trying to plot two motions at the same time, but because of the first drawnow, the second one does not plot at the same time. Could you help me?
Thanks, -Felipe
Meshooo
Meshooo 2014-12-5
Sure, try to run this code
for K = 1:200
A1 =sort(rand(K,1))*2*pi;
B1 =sort(rand(K,1))*2*pi;
subplot(1,2,1)
grid on
plot(A1, 'r', 'linewidth',2);
drawnow
hold on
subplot(1,2,2)
plot(B1, 'b', 'linewidth',2);
grid on
drawnow
pause(0.01);
end
I hope it's what you want.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Graphics Performance 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by