How to update a plot/graph?

40 次查看(过去 30 天)
Hello everybody,
I got a plot like this one:
h = subplot(1,2,1);
plot(0, 0);
axis([-30 40 -20 100 ]);
grid on
Now I am getting a new array of x,y - points every second. How can I update the subplot h with these arrays? It is an n by 2 single array.
Thank you in advance!
Lucca

采纳的回答

Image Analyst
Image Analyst 2015-11-9
In your loop where you get new x,y arrays, make sure you have this line after the plot:
plot(.................
drawnow;
drawnow will force the plot to update immediately. Otherwise it probably won't get around to it until the loop is entirely finished so that all you will see is the very last set of data plotted.
  2 个评论
Sepehr Ariaei
Sepehr Ariaei 2021-6-27
Does drawnow works on semilogy too?
Walter Roberson
Walter Roberson 2021-6-27
Yes, drawnow() works on all graphics updates.

请先登录,再进行评论。

更多回答(1 个)

Thorsten
Thorsten 2015-11-9
编辑:Thorsten 2015-11-9
subplot(1,2,1);
plot(x, y);
drawnow

类别

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

Community Treasure Hunt

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

Start Hunting!

Translated by