Programming and Data Types | ![]() ![]() |
Starting and Stopping Timers
After you create a timer object, you can start the timer by calling either the start
or startat
function.
Note Because the timer works within the MATLAB single-threaded environment, it cannot guarantee execution times or execution rates. |
The start
function starts the timer immediately, changing the value of the timer object's Running
property from 'off'
to 'on'
:
The start
function returns control to the MATLAB command line immediately. You can also choose to wait until the timer callback function (TimerFcn
) executes before returning control to the command line. See Blocking the MATLAB Command Line for more information.
The startat
function starts the timer immediately and sets the value of the StartDelay
property to the time you specify:
Note
The timer object can execute a callback function that you specify when it starts. See Creating Timer Callback Functions for more information about using the StartFcn property.
|
Blocking the MATLAB Command Line
By default, when you start a timer, the start
or startat
function returns control to the command line immediately. If your application must wait until the function controlled by the timer executes, use the wait
function right after calling the start function:
Stopping Timers
The timer stops running if one of the following conditions apply:
TimerFcn
) has been executed the number of times specified in the TasksToExecute
property.
stop
command is issued.
TimerFcn
).
When a timer stops, the value of the Running
property of the timer object is 'off'
.
Note
The timer object can execute a callback function that you specify when it stops. See Creating Timer Callback Functions for more information about using the StopFcn property.
|
![]() | Timer Object Properties | Timer Object Execution Modes | ![]() |