Create object to schedule execution of MATLAB commands
Use a timer object to schedule the execution
of MATLAB® commands one or multiple times. If you schedule the
timer to execute multiple times, you can define the time between executions
and how to handle queuing conflicts.
The timer object uses callback functions
to execute commands. Callback functions execute code during some event.
For the timer object, you can specify the callback
function as a function handle or as a character vector. If the callback
function is a character vector, MATLAB evaluates it as executable
code. The timer object supports callback functions when a timer starts
(StartFcn), executes (TimerFcn),
stops (StopFcn), or encounters an error (ErrorFcn).
Note
The timer object is subject to the limitations
of your hardware, operating system, and software. Avoid using timer
objects for real-time applications.
creates
an empty t = timertimer object to schedule execution of MATLAB commands.
An error occurs if the timer starts and TimerFcn is
not defined.
creates
a t = timer(Name,Value)timer object with additional options that you
specify using one or more Name,Value pair arguments.
Specify optional
comma-separated pairs of Name,Value arguments. Name is
the argument name and Value is the corresponding value.
Name must appear inside quotes. You can specify several name and value
pair arguments in any order as
Name1,Value1,...,NameN,ValueN.
The argument name, Name, corresponds to a timer property
name. In the constructor, the property values are specified using Name,Value pair
arguments.
|
Character vector or string scalar that indicates action taken when a timer has to execute
See Handling Timer Queuing Conflicts for more information. Default: | ||||||||||||||||
|
Character vector, string scalar, function handle, or cell array defining the function that the
timer executes when an error occurs. If there is an error, this function executes, and then
calls
For more information, see Timer Callback Functions. | ||||||||||||||||
|
Character vector or string scalar that defines how the
Default: | ||||||||||||||||
|
Character vector or string scalar representing the Default: | ||||||||||||||||
|
Character vector or string scalar with possible values of Default: | ||||||||||||||||
|
Number greater than 0.001 that specifies the delay, in seconds,
between executions of Default: 1.0 | ||||||||||||||||
|
Number greater than or equal to 0 that specifies the delay,
in seconds, between the start of the timer and the first execution
of the function specified in Default: 0 | ||||||||||||||||
|
Character vector, string scalar, function handle, or cell array defining the function that executes when the timer starts.
For more information, see Timer Callback Functions. | ||||||||||||||||
|
Character vector, string scalar, function handle, or cell array defining the function that executes when the timer stops.
For more information, see Timer Callback Functions. The timer stops when
You can use | ||||||||||||||||
|
Character vector or string scalar that represents a label for the object. | ||||||||||||||||
|
Number greater than 0, indicating the number of times the timer
object is to execute the Default: | ||||||||||||||||
|
Character vector, string scalar, function handle, or cell array defining the timer callback function. You must define this property before you can start the timer.
For more information, see Timer Callback Functions. | ||||||||||||||||
|
Generic field for data that you want to add to the object. |
|
Average time in seconds between |
|
The time in seconds between the last
two executions of |
|
Character vector defined as |
|
The number of times the timer called |
|
Character vector that identifies the object type. |
| delete | Remove timer object from memory |
| get | Query property values for timer object |
| isvalid | Determine timer object validity |
| set | Set property values for timer object |
| start | Start timer object |
| startat | Schedule timer to fire at specified time |
| stop | Stop timer object |
| timerfind | Find timer object |
| timerfindall | Find timer object, regardless of visibility |
| wait | Block command prompt until timer stops running |
Handle. To learn how handle classes affect copy operations, see Copying Objects.
To force the execution of the callback functions in
the event queue, include a call to the drawnow function
in your code. The drawnow function flushes the
event queue.