Matlab Timer回调函数的执行中rawnow函数的用途是什么

发布时间:2021-10-14 10:07:24 作者:柒染
来源:亿速云 阅读:157

本篇文章为大家展示了Matlab Timer回调函数的执行中rawnow函数的用途是什么 ,内容简明扼要并且容易理解,绝对能使你眼前一亮,通过这篇文章的详细介绍希望你能有所收获。

    由前一篇文章可以看出,按照所设定的时间间隔调用Timer的回调函数时,并不是真的即刻执行该回调函数,而是先将该回调函数放入事件队列中,待前面的事件都执行完时才执行该事件。但有时我们需要当所设定的时间到达时立刻执行我们的回调函数,此时我们就可以用功能强大的drawnow函数了。在回调函数中加入drawnow就可以在时间到达时强制执行该回调函数。

下面给出的是matlab帮助里关于drawnow的用法:

drawnow

Flush event queue and update figure window
Syntax

drawnow
drawnow expose
drawnow update
Description

drawnow causes figure windows and their children to update and flushes the system event queue. Any callbacks generated by incoming events (e.g. mouse or key events) are dispatched before drawnow returns.

drawnow expose causes only graphics objects to refresh, if needed. It does not allow callbacks to execute and does not process other events in the queue.

drawnow update causes only non-graphics objects to refresh, if needed. It does not allow callbacks to execute and does not process other events in the queue.

You can combine the expose and update options to obtain both effects.

drawnow expose update

Other Events That Cause Event Queue Processing

Other events that cause MATLAB to flush the event queue and draw the figure includes:

    *

      Returning to the MATLAB prompt
    *

      Executing the following functions
          o

            figure
          o

            getframe
          o

            input
          o

            keyboard
          o

            pause
    *

      Functions that wait for user input (i.e., waitforbuttonpress, waitfor, ginput)
    *

      Any code that causes one of the above functions to be executed. For example, suppose h is the handle of an axes. Calling axes(h) causes its parent figure to be made the current figure and brought to the front of all displayed figures, which results in the event queue being flushed.

Examples

Using drawnow in a loop causes the display to update while the loop executes:

t = 0:pi/20:2*pi;
y = exp(sin(t));
h = plot(t,y,'YDataSource','y');
for k = 1:.1:10
 y = exp(sin(t.*k));
 refreshdata(h,'caller') % Evaluate y in the function workspace
 drawnow; pause(.1)
end

上述内容就是Matlab Timer回调函数的执行中rawnow函数的用途是什么 ,你们学到知识或技能了吗?如果还想学到更多技能或者丰富自己的知识储备,欢迎关注亿速云行业资讯频道。

推荐阅读:
  1. MatLab学习笔记
  2. matlab中的fprintf函数怎么用

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

matlab timer

上一篇:如何使用Vim/Neovim/SpaceVim

下一篇:是什么递归函数

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》