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.

10 Scheduling Program Execution with Timers<br />

Executing a Timer Callback Function Multiple Times<br />

The timer object supports three multiple-execution modes:<br />

• 'fixedRate'<br />

• 'fixedDelay'<br />

• 'fixedSpacing'<br />

In many ways, these execution modes operate the same:<br />

• The TasksToExecute property specifies the number of times you want the<br />

timer to execute the timer callback function (TimerFcn).<br />

• The Period property specifies the amount of time between executions of<br />

the timer callback function.<br />

• The BusyMode property specifies how the timer object handles queuing of<br />

the timer callback function when the previous execution of the callback<br />

function has not completed. See “Handling Callback Function Queuing<br />

Conflicts” on page 10-21 for more information.<br />

The execution modes differ only in where they start measuring the time<br />

period between executions.Thefollowingtable describes these differences.<br />

Execution<br />

Mode<br />

'fixedRate'<br />

'fixedDelay'<br />

'fixedSpacing'<br />

Description<br />

Time period between executions beginsimmediatelyafter<br />

the timer callback function is added to the <strong>MATLAB</strong><br />

execution queue.<br />

Time period between executions begins when the timer<br />

function callback actually starts executing, after any time<br />

lag due to delays in the <strong>MATLAB</strong> execution queue.<br />

Time period between executions begins when the timer<br />

callback function finishes executing.<br />

The following figure illustrates the difference between these modes. Note that<br />

the amount of time between executions (specified by the Period property)<br />

remains the same. Only the point at which execution begins is different.<br />

10-20

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

Saved successfully!

Ooh no, something went wrong!