start - Start timer - MATLAB (original) (raw)
Syntax
Description
start([t](#mw%5Ffd0fa37d-a700-4c58-8eb5-d8b52364de15))
starts the timert
. If t
is an array of timers,start
starts all the timers.
The start
function sets the Running
property of the timer to 'on'
, executes the StartFcn
callback, and initiates TimerFcn
callback.
Examples
Start Timer
Use start
to start a timer.
Create and start a timer that displays the message "timer started." as theStartFcn
callback and generates a random number as theTimerFcn
callback. Delete the timer.
t = timer('StartFcn',@(,)disp('timer started.'),...
'TimerFcn',@(,)disp(rand(1)));
start(t)
delete(t)
Your output from rand
will vary.
Start Several Timers
Use start
to begin multiple timers.
Create and start three timers that display message for theStartFcn
callbacks. Compute the sine, cosine, and tangent ofpi/4
as the TimerFcn
callbacks. Delete the timers.
t1 = timer('StartFcn',@(,)disp('t1 started.'),...
'TimerFcn',@(,)sin(pi/4));
t2 = timer('StartFcn',@(,)disp('t2 started.'),...
'TimerFcn',@(,)cos(pi/4));
t3 = timer('StartFcn',@(,)disp('t3 started.'),...
'TimerFcn',@(,)tan(pi/4));
start([t1 t2 t3]);
delete([t1 t2 t3]);
t1 started. t2 started. t3 started.
Input Arguments
t
— timer
timer | array of timers
Timer to start, specified as a timer or array of timers.
Version History
Introduced before R2006a