How to make a forced exit from Matlab with returning a code?

15 visualizaciones (últimos 30 días)
Ralf
Ralf el 26 de Oct. de 2018
Comentada: Walter Roberson el 29 de Oct. de 2018
Hi all, I try to exit from Matlab in a script and want to return a code to the command line. I know that there is the command
exit(code);
to do that. But in my case, some unsaved Simulink files prevent me from exiting. That's why I use
exit force;
to exit from Matlab without beeing asked to save the file first. But this command does not allow to pass a code to the command line. I tried something like
exit(code, 'force')
But that didn't work. Any other ideas?
Thanks a lot, Ralf

Respuestas (2)

yusra Ch
yusra Ch el 26 de Oct. de 2018
in the command window do this: ctrl+c and it will force the code to stop running
  1 comentario
Ralf
Ralf el 29 de Oct. de 2018
Sorry, I need to exit from a Matlab script. I am not sitting in front of the PC when this (batch of) scripts run.

Iniciar sesión para comentar.


madhan ravi
madhan ravi el 26 de Oct. de 2018
Editada: madhan ravi el 29 de Oct. de 2018
exit %edited after sir Walter’s comment
  7 comentarios
Ralf
Ralf el 29 de Oct. de 2018
Thank you, Walter. But is there a way to combine an exit code with the force statement?
Walter Roberson
Walter Roberson el 29 de Oct. de 2018
It turns out that although the two are documented differently, they take the same options. However, only one option is permitted; it must be 'force' or 'cancel' or a scalar integer (negative values are permitted.) It is possible that there are additional undocumented options.

Iniciar sesión para comentar.

Categorías

Más información sobre Startup and Shutdown en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by