Borrar filtros
Borrar filtros

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

23 visualizaciones (últimos 30 días)
Meshooo
Meshooo el 8 de Oct. de 2014
Comentada: Meshooo el 5 de Dic. de 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

Respuesta aceptada

Thorsten
Thorsten el 8 de Oct. de 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 comentarios
Felipe
Felipe el 4 de Dic. de 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 el 5 de Dic. de 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.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Graphics Performance en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by