十年网站开发经验 + 多家企业客户 + 靠谱的建站团队
量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决
本篇文章为大家展示了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函数的用途是什么 ,你们学到知识或技能了吗?如果还想学到更多技能或者丰富自己的知识储备,欢迎关注创新互联行业资讯频道。