How to exit MATLAB after completion of a command?

Instead of writing quitin my .mfile, can I do this with a command? I want to close MATLAB right after the file completes.

For example, this is my team

matlab -nodisplay < my_script

Many thanks.


This is the actual team I tried to make

matlab -nodisplay -nodesktop -nosplash -nojvm -r "try, basic_plot;end, quit"
+5
source share
2 answers
matlab -nosplash -nodesktop -r "my_script; quit"

Edit:

Following Eric's recommendation, you better use one of them:

matlab -nosplash -nodesktop -r "try, my_script; end, quit"
matlab -nosplash -nodesktop -r "try, my_script; catch, disp('failed'), end, quit"
matlab -nosplash -nodesktop -r "try, my_script; catch e, your_error_handling_function(e), end, quit"
+14
source

write in the last line of your .m file, and when you run your simulation after it shows the result, it will exit by itself.

[...] % code

quit
-1
source

All Articles