title: How to call MATLAB script from command line?
body: <p>I have been trying to call matlab from Terminal (I have a Mac) and have it simply run a program for me, without display or anything, just the program. This program both displays graphs and writes a text file for me to use. I have found several of the previous answers on this question, and so I have tried:</p>
  
  <pre><code>   matlab -nodisplay -r foo 
  
     matlab -nodisplay -r foo.m 
  
     matlab -nojvm -nosplash -nodisplay -r foo;quit; 
  
     matlab -nojvm -nosplash -nodisplay -r "foo;quit;" 
  
     matlab -nojvm -nodesktop -r "foo;quit;" 
  
     matlab -nojvm -nodesktop -r
     "foo" 
  
     matlab -nojvm -nodesktop -nosplash -r foo
  </code></pre>
  
  <p>Pretty much every time I try it, I keep getting the same response (when the line just doesn't cause the prompt to say "screw you" and give up): the actual MATLAB program <em>window</em> will open, and it will stay open. It will interact normally. And command line won't do anything until I close out the window. The program I want doesn't run. The window just... sits there. </p>
  
  <p>If it helps, this is how I have <code>matlab</code> coded in my bin:</p>
  
  <pre><code>#!/bin/bash                                                                                             
  
  /Applications/MATLAB_R2015b.app/bin/matlab
  </code></pre>
  
  <p>I have no clue what is going on. Any help would be greatly appreciated.</p>