23.06.2015 Views

MATLAB Programming

MATLAB Programming

MATLAB Programming

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Creating and Executing Callback Functions<br />

Timer Object Events and Related Callback Function<br />

Creating Callback Functions<br />

When the time period specified by a timer object elapses, the timer object<br />

executes one or more <strong>MATLAB</strong> functions of your choosing. You can specify<br />

the functions directly as the value of the callback property. You can also put<br />

the commands in an M-file function and specify the M-file function as the<br />

value of the callback property.<br />

Specifying Callback Functions Directly<br />

This example creates a timer object that displays a greeting after 5 seconds.<br />

The example specifies the value of the TimerFcn callback property directly,<br />

putting the commands in a text string.<br />

t = timer('TimerFcn','disp(''Hello World!'')','StartDelay',5);<br />

10-15

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

Saved successfully!

Ooh no, something went wrong!