Instead of writing quit
in my .m
file, can I do this through command? I want to close MATLAB right after the file execution is completed.
F
write down in the last line of your .m file and when you run your simulation after it shows result it will quit itself.
[...] % code
quit
matlab -nosplash -nodesktop -r "my_script; quit"
Following Edric's recommendation, you'd better use one of these:
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"