Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

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

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

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.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report