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

3 visualizaciones (últimos 30 días)
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 ?

Respuesta aceptada

Star Strider
Star Strider el 25 de Abr. de 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 comentarios
Shounak Shastri
Shounak Shastri el 26 de Abr. de 2014
Thanks ... 'fprintf' and 'save' really helped
Star Strider
Star Strider el 26 de Abr. de 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.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Programming en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by