Main Content





start(t) starts the timer t. 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.


collapse all

Use start to start a timer.

Create and start a timer that displays the message "timer started." as the StartFcn callback and generates a random number as the TimerFcn callback. Delete the timer.

t = timer('StartFcn',@(~,~)disp('timer started.'),...
timer started.

Your output from rand will vary.

Use start to begin multiple timers.

Create and start three timers that display message for the StartFcn callbacks. Compute the sine, cosine, and tangent of pi/4 as the TimerFcn callbacks. Delete the timers.

t1 = timer('StartFcn',@(~,~)disp('t1 started.'),...
t2 = timer('StartFcn',@(~,~)disp('t2 started.'),...
t3 = timer('StartFcn',@(~,~)disp('t3 started.'),...
start([t1 t2 t3]);
delete([t1 t2 t3]);
t1 started.
t2 started.
t3 started.

Input Arguments

collapse all

Timer to start, specified as a timer or array of timers.

See Also

| | |

Introduced before R2006a