Skip to Main Content Skip to Search
Product Documentation

pause - Halt execution temporarily

Syntax

pause
pause(n)
pause on
pause off
pause query
state = pause('query')
oldstate = pause(newstate)

Description

pause, by itself, causes the currently executing function to stop and wait for you to press any key before continuing. Pausing must be enabled for this to take effect. (See pause on, below). pause without arguments also blocks execution of Simulink models, but not repainting of them.

pause(n) pauses execution for n seconds before continuing, where n is any nonnegative real number. Pausing must be enabled for this to take effect.

Typing pause(inf) puts you into an infinite loop. To return to the MATLAB prompt, type Ctrl+C.

pause on enables the pausing of MATLAB execution via the pause and pause(n) commands. Pausing remains enabled until you enter pause off in your function or at the command line.

pause off disables the pausing of MATLAB execution via the pause and pause(n) commands. This allows normally interactive scripts to run unattended. Pausing remains disabled until you enter pause on in your function or at the command line, or start a new MATLAB session.

pause query displays 'on' if pausing is currently enabled. Otherwise, it displays 'off'.

state = pause('query') returns 'on' in character array state if pausing is currently enabled. Otherwise, the value of state is 'off'.

oldstate = pause(newstate), enables or disables pausing, depending on the 'on' or 'off' value in newstate, and returns the former setting (also either 'on' or 'off') in character array oldstate.

Tips

The accuracy of pause is subject to the scheduling resolution of the operating system you are using, and also to other system activity. It cannot be guaranteed with 100% confidence. Asking for finer resolutions shows higher relative error.

While MATLAB is paused, the following continue to execute:

See Also

drawnow | input | keyboard

  


Free MATLAB Interactive Kit

Explore how to use MATLAB to make advancements in engineering and science.


Download free kit

Trials Available

Try the latest version of MATLAB and other MathWorks products.


Get trial software
 © 1984-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS