views:

1263

answers:

2

I'm running a long simulation in MATLAB that I've realized I need to stop and rerun. However, MATLAB is really into this calculation, and it's stopped responding. How can I interrupt this run without killing MATLAB?

(I realize this is a problem with many Windows programs, but it's really acute with MATLAB.)

+4  A: 

Go to the command window, and hit Ctrl-C a lot. From my experience, on a single-core machine you do not have a chance, unless you do lots of output. On a multi-core or multi-processor machine, you'll probably stop it eventually, but it takes time.

See also http://www.mathworks.com/support/solutions/en/data/1-188VX/index.html

Added: it is a good practice to (1) save a snapshot of your workspace before running anything really long and (2) withing a very long calculation, write some of the variables to a file from time to time, so that you can resume the calculation if it was interrupted (by power failure, e.g.).

AVB
I agree, but sometimes I kill it with the Windows Task Manager rather than bashc Ctrl-C like a demented monkey.
High Performance Mark
+1: Hitting CTRL-C like a maniac usually works, but there are situations when shutting down everything is all that works. Which is a bit annoying to say the least...
kigurai
+1  A: 

How well MATLAB responds to CTRL-C rather depends on what it's doing. If it's in the middle of a BLAS or LAPACK call for example, it will not respond until that call returns. If you're in a block of code where lots of lines of MATLAB are being executed, you can expect CTRL-C to be more responsive.

Edric