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

4 visualizzazioni (ultimi 30 giorni)
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 ?

Risposta accettata

Star Strider
Star Strider il 25 Apr 2014
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 Commenti
Star Strider
Star Strider il 26 Apr 2014
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.

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Programming in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by