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

3 次查看(过去 30 天)
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 ?

采纳的回答

Star Strider
Star Strider 2014-4-25
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.
  2 个评论
Star Strider
Star Strider 2014-4-26
My pleasure!
I learned both by experience, over 20 years of using MATLAB, beginning when computers were very slow and running very large simulations. I also used the File Exchange function morspeak to notify me audibly when my routine got to the end of a loop. (I’m an amateur radio operator, so I could ‘copy’ the code. The morspeak function isn’t on the File Exchange any more, but I’ll post it here if you want it.) I also used ‘train.mat’ to let me know when the routine had finished.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Programming 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by