wait

Class: timer

Block command prompt until timer stops running

Syntax

Description

example

wait(t) blocks the command prompt until timer, t, stops running. If t is an array of timer objects, wait blocks the MATLAB® command line until each timer in t has stopped running.

To block the command line, the timer object must first start via start or startat before calling the wait method. If the timer is not running, wait returns immediately.

Input Arguments

t

Array of timer objects

Examples

expand all

Create a timer that waits 10 seconds, and then displays a message. Start the timer and wait for it to finish.

T = timer('TimerFcn',@(~,~)disp('Fired.'),'StartDelay',10);
start(T)
Fired.

Notice that after the timer starts, the MATLAB prompt returns.

Start the timer and use the wait method to block anyone from entering commands at the MATLAB command line. You must start the timer before calling the wait command.

start(T)
wait(T)
Fired.

Notice that after the timer starts, the MATLAB prompt disappears until the timer stops.

Delete the timer.

delete(T)

See Also

|

Introduced before R2006a