溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

Matlab Timer回調(diào)函數(shù)的執(zhí)行中rawnow函數(shù)的用途是什么

發(fā)布時(shí)間:2021-10-14 10:07:24 來源:億速云 閱讀:154 作者:柒染 欄目:編程語言

本篇文章為大家展示了Matlab Timer回調(diào)函數(shù)的執(zhí)行中rawnow函數(shù)的用途是什么 ,內(nèi)容簡(jiǎn)明扼要并且容易理解,絕對(duì)能使你眼前一亮,通過這篇文章的詳細(xì)介紹希望你能有所收獲。

    由前一篇文章可以看出,按照所設(shè)定的時(shí)間間隔調(diào)用Timer的回調(diào)函數(shù)時(shí),并不是真的即刻執(zhí)行該回調(diào)函數(shù),而是先將該回調(diào)函數(shù)放入事件隊(duì)列中,待前面的事件都執(zhí)行完時(shí)才執(zhí)行該事件。但有時(shí)我們需要當(dāng)所設(shè)定的時(shí)間到達(dá)時(shí)立刻執(zhí)行我們的回調(diào)函數(shù),此時(shí)我們就可以用功能強(qiáng)大的drawnow函數(shù)了。在回調(diào)函數(shù)中加入drawnow就可以在時(shí)間到達(dá)時(shí)強(qiáng)制執(zhí)行該回調(diào)函數(shù)。

下面給出的是matlab幫助里關(guān)于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

上述內(nèi)容就是Matlab Timer回調(diào)函數(shù)的執(zhí)行中rawnow函數(shù)的用途是什么 ,你們學(xué)到知識(shí)或技能了嗎?如果還想學(xué)到更多技能或者豐富自己的知識(shí)儲(chǔ)備,歡迎關(guān)注億速云行業(yè)資訊頻道。

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI