Main Content

wait

Block command prompt until timer stops running

Syntax

Description

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 by using start or startat before calling the wait method. If the timer is not running, wait returns to the command line immediately.

example

Examples

collapse 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.

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. Before calling the wait command, you must start the timer.

start(T)
wait(T)
Fired.

After the timer starts, the MATLAB prompt is not visible until the timer stops.

Delete the timer.

delete(T)

Input Arguments

collapse all

Timer, specified as a timer object or array of timer objects.

Example: wait(t)

Version History

Introduced before R2006a

See Also

| | |