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.