stop

Method of timer objects: stops a running timer.

Category: Programming > Programming Utilities

Syntax

stop(t)

Stops the timer t so that no further callbacks are made.

Description

After stop, the Running property of the timer returns to 'off'. Stopping a timer does not delete it; it can be started again with start. Stopping a timer that is not running does nothing.

Input arguments

t
A timer object, or an array of timers.

Example

Cancelling before it fires

t = timer('StartDelay', 5, 'TimerFcn', @(~,~) disp('never printed'));
start(t)
disp(t.Running)
stop(t)
disp(t.Running)
delete(t)
Output
on
off

See also

timer start wait delete