您好,登錄后才能下訂單哦!
本篇文章為大家展示了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函數的用途是什么 ,你們學到知識或技能了嗎?如果還想學到更多技能或者豐富自己的知識儲備,歡迎關注億速云行業資訊頻道。
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。