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.

More About

expand all

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:

  • Repainting of figure windows, Simulink block diagrams, and Java® windows

  • HG callbacks from figure windows

  • Event handling from Java windows

See Also

| |

Was this topic helpful?