23.06.2015 Views

MATLAB Programming

MATLAB Programming

MATLAB Programming

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Using a <strong>MATLAB</strong> Timer Object<br />

Using a <strong>MATLAB</strong> Timer Object<br />

To use a timer, perform these steps:<br />

1 Create a timer object.<br />

You use the timer function to create a timer object. See “Creating Timer<br />

Objects” on page 10-5 for more information.<br />

2 Specify which <strong>MATLAB</strong> commands you want executed when the timer fires<br />

and control other aspects of timer object behavior.<br />

You use timer object properties to specify this information. To learn about<br />

all the properties supported by the timer object, see “Working with Timer<br />

Object Properties” on page 10-7. (You can also set timer object properties<br />

when you create them,instep1.)<br />

3 Start the timer object.<br />

After you create the timer object, you must start it, using either the start<br />

or startat function. See “Starting and Stopping Timers” on page 10-10<br />

for more information.<br />

4 Delete the timer object when you are done with it.<br />

After you are finished using a timer object, you should delete it from<br />

memory. See “Deleting Timer Objects from Memory” on page 10-23 for<br />

more information.<br />

Note The specified execution time and the actual execution of a timer can<br />

vary because timer objects work in the <strong>MATLAB</strong> single-threaded execution<br />

environment. The length of this time lag is dependent on what other<br />

processing <strong>MATLAB</strong> is performing. To force the execution of the callback<br />

functions in the event queue, include a call to the drawnow function in your<br />

code. The drawnow function flushes the event queue.<br />

10-3

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!