How to run Matlab from the command line?

macos, matlab

Solution

The `matlab` script is in the `bin` subdirectory of the MATLAB app bundle. On my machine, this means I can run it like so:

/Applications/MATLAB_R2012a_Student.app/bin/matlab

If you want this bin directory on your path (so that you can just run `matlab`, `mex`, etc), edit or create a new text file called `.bash_profile` in the top level of your home directory with the following line:

export PATH=/Applications/MATLAB_R2012a_Student.app/bin:$PATH

Replacing the "MATLAB_R2012a_Student" part with the name of your actual MATLAB app bundle. This will not come into effect for currently open terminals, but newly opened terminals should work properly.

Problem

Is it possible to run Matlab commands from Mac command line?

Original source