Get the App
SLTechnology News&Howtos  ›  Development  › 

What is the purpose of the rawnow function in the execution of the Matlab Timer callback function

Shulou Source: shulou.com Published: 2022-06-03 05:52:52 11月17日 Update

This article shows you what is the use of the rawnow function in the implementation of the Matlab Timer callback function, the content is concise and easy to understand, it can definitely brighten your eyes. I hope you can get something through the detailed introduction of this article.

As you can see from the previous article, when the callback function of Timer is called at a set time interval, the callback function is not really executed immediately, but is put into the event queue first, and the event is not executed until all the previous events have been executed. But sometimes we need to execute our callback function as soon as the set time arrives, so we can use the powerful drawnow function. Adding drawnow to the callback function forces the callback function to be executed when the time arrives.

The following is the use of drawnow in the matlab help:

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 waitfor 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.jiny.com, yDataSource.com, etc.)

For k = 1VOL .1VOL 10

Y = exp (sin (t.pragk))

Refreshdata (hpencil caller')% Evaluate y in the function workspace

Drawnow; pause (.1)

End

The above is what is the use of the rawnow function in the execution of the Matlab Timer callback function. Have you learned the knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.

Tags: Functions events time use content skills knowledge articles powerful concise concise functional powerful that is articles more but industry information information channels Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Huawei NVidia OPPO Reno macOS Linux