Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run Matlab from the command line?

Tags:

macos

matlab

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

like image 453
Stan Avatar asked Apr 20 '12 14:04

Stan


People also ask

How do I run a MATLAB script from the Command Window?

Type the script name on the command line and press Enter. For example, to run the numGenerator. m script, type numGenerator . On the Editor tab, click the Run button.

How do I start MATLAB from command line Linux?

To start MATLAB® on Linux platforms, type matlab at the operating system prompt. If you did not set up symbolic links in the installation procedure, then type matlabroot /bin/matlab . matlabroot is the name of the folder in which you installed MATLAB.

Which is the MATLAB command prompt?

The Command Window enables you to enter individual statements at the command line, indicated by the prompt (>>). As you enter statements, the Command Window displays the results. For example, to create the variable a , type a = 1 at the command line and press Enter.


2 Answers

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.

like image 179
kwatford Avatar answered Oct 19 '22 05:10

kwatford


You need the full path to the MATLAB executable, and you can use the -r option to run a command in the MATLAB that you start, as per the doc here.

like image 42
Edric Avatar answered Oct 19 '22 05:10

Edric