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

27 Ansichten (letzte 30 Tage)
Meshooo
Meshooo am 8 Okt. 2014
Kommentiert: Meshooo am 5 Dez. 2014
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

Akzeptierte Antwort

Thorsten
Thorsten am 8 Okt. 2014
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 Kommentare
Felipe
Felipe am 4 Dez. 2014
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 am 5 Dez. 2014
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.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Graphics Performance finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by