Main Content

Stop Execution

To stop execution of a MATLAB® command, press Ctrl+C or Ctrl+Break.

On Apple Macintosh platforms, you also can use Command+. (the Command key and the period key).

Ctrl+C does not always stop execution for files that run a long time, or that call built-ins or MEX-files that run a long time. If you experience this problem, include a drawnow, pause, or getframe function in your file, for example, within a large loop. Also, Ctrl+C might be less responsive if you start MATLAB with the -nodesktop option.

Note

For certain operations, stopping the program might generate errors in the Command Window.

To programmatically stop execution of a function or script before reaching the end, use the return function. MATLAB returns control to the Command Window or the invoking function.

See Also

| | |