Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

start

Class: timer

Start timer object

Syntax

Description

example

start(t) starts the timer object, t. If t is an array of timer objects, start starts all the timers.

The start method sets the Running property of the timer object to 'on', executes the StartFcn callback, and initiates TimerFcn callback .

Input Arguments

t

Object of class timer.

Examples

expand all

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.'),'TimerFcn',@(~,~)disp(rand(1)));
start(t)
delete(t)
timer started.
    0.9706

Your output from rand will vary.

Create and start three timers that displays a message for the StartFcn callbacks and compute the sine, cosine, and tangent of pi/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.

See Also

| | |

Introduced before R2006a

Was this topic helpful?