MATLAB: Is there any way of stopping the execution of a program in the middle

executing a program

My code is now running for 10 minutes.
Is there any way i can pause or stop the execution and see the current status of my variables ?

Best Answer

If your program is looping, a common method is to use fprintf to print out selected interim values at the end of each loop. (I usually also print out the time and the elapsed time as well, so I can get an idea of how long the entire process is going to take.) If you are doing a nonlinear curve fit, integrating a differential equation, or some other function that iterates on its own, you options are limited to those available in the function. If your program runs for a very long time, I strongly suggest putting a save statement at the end of every loop iteration to write necessary interim results to disk.
Be careful about using CTRL+C, since it stops your program and also resets everything, forcing you to start over.