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

조회 수: 33 (최근 30일)
Meshooo
Meshooo 2014년 10월 8일
댓글: Meshooo 2014년 12월 5일
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