How to make a forced exit from Matlab with returning a code?
显示 更早的评论
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
回答(2 个)
yusra Ch
2018-10-26
1 个投票
in the command window do this: ctrl+c and it will force the code to stop running
madhan ravi
2018-10-26
编辑:madhan ravi
2018-10-29
exit %edited after sir Walter’s comment
7 个评论
madhan ravi
2018-10-26
in command window
Ralf
2018-10-29
madhan ravi
2018-10-29
Try it in your script and experiment what happens
Walter Roberson
2018-10-29
编辑:Walter Roberson
2018-10-29
There is no leave in MATLAB. There are exit and quit.
exit supports a return code but quit does not.
madhan ravi
2018-10-29
编辑:madhan ravi
2018-10-29
Ah Thank you sir Walter till date I had been using it together but didn’t looked into it so deeper though :)
Ralf
2018-10-29
Walter Roberson
2018-10-29
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.
类别
在 帮助中心 和 File Exchange 中查找有关 Startup and Shutdown 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!