MATLAB 中的实时绘图 [英] Real time plot in MATLAB

查看:79
本文介绍了MATLAB 中的实时绘图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对 MATLAB 非常陌生,我试图显示一些计算的实时图.我有一个 N 大小的向量,我一次使用 m 值(比如 m = N/4),所以我想绘制第一个 m 值,然后在计算第二个 m 值后立即用它们替换第一个图.

I'm very new to MATLAB and I was trying to display a real time plot of some calculations. I have an N sized vector and I work with m values at a time (say m = N/4), so I want to plot the first m values and then as soon as the second m values are calculated have them replace the first plot.

我的方法如下:

for i=1:N,
  ...
  //compute m
  ...
  plot(m);
end;

但它无法在每个循环中更新绘图并等待所有循环完成以绘制数据.我的问题是:我应该使用另一个函数而不是 plot 还是可以在每个循环中添加一些延迟?

but it fails to update the plot in every loop and waits for all the loops to finish to plot the data. My question is: Should I use another function instead of plot or could I add some delay in each loop?

我认为必须有一种我不知道的方法来更新情节而不是每次都重新绘制它.

I think there must be a way I'm not aware of for updating the plot instead of re-plotting it every time.

推荐答案

您可以添加对 DRAWNOW 的调用以强制更新绘图.请参阅参考页面.请注意,DRAWNOW 会导致图形事件队列被刷新,这可能会导致执行回调等.

You can add a call to DRAWNOW to force the plot to update. See the reference page. Note that DRAWNOW causes the graphics event queue to be flushed, which may cause callbacks etc. to be executed.

这篇关于MATLAB 中的实时绘图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆