Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

1 Answer 1

Here is the answer by @Simon on Stack Overflow:

matlab -nosplash -nodesktop -r "my_script; quit"

Edit:

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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.