Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a Matlab script named "main_wrapper.m" in my /home/user/MATLAB directory. I want to call this script from the Unix command line. This script ends with a quit, so it's expected to quit by itself. I want to call this script from the command line and have it quit all by itself.

I don't get results with:

shell$ cd /home/user/MATLAB/ && /usr/local/MATLAB/R2011b/bin/matlab -nosplash -nodesktop -r main_wrapper.m

or with /usr/local/MATLAB/R2011b/bin/matlab -r " cd /home/user/MATLAB; run (/home/user/MATLAB/main_wrapper); end; quit "

In either case MATLAB window opens up and doesn't run by itself.

How can I get the window to quit?

share|improve this question

Here is the answer by @Simon on Stack Overflow:

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"
share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .