This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

matlab (Mac)

Start MATLAB program from macOS Terminal


matlab option1 ... optionN



matlab is a Bourne shell script that starts the MATLAB® program from a Mac system prompt. Here the term matlab refers to this script and MATLAB refers to the program.

The matlab script is located in the MATLAB application package, /Applications/matlabroot/, where matlabroot is the name of the folder in which you installed MATLAB and release is the MATLAB release number.

The matlab script:

  • Determines the MATLAB root folder, the value returned by the matlabroot function

  • Processes command-line options, if any

  • Reads the MATLAB startup file,

  • Sets MATLAB environment variables


matlab option1 ... optionN starts MATLAB with the specified startup options.

Alternatively, assign startup options in the MATLAB Startup File. Modifying the file defines startup options every time you start MATLAB. On macOS platforms, the file applies only when starting MATLAB from Terminal. The file does not apply when starting MATLAB by double-clicking the MATLAB icon in the Applications folder.

MATLAB uses the Java® Virtual Machine (JVM™) software to run the desktop and to display graphics. The -nojvm option enables you to start MATLAB without the JVM. Using this option minimizes memory usage and improves initial startup speed, but restricts functionality.

Input Arguments

expand all

One or more startup options, specified as strings corresponding to valid startup options from the following tables.

Mode Options


Start MATLAB without a controlling terminal. Use this option when you start MATLAB from a window manager menu or desktop icon.


Run the JVM software without opening the MATLAB desktop. You can use development environment tools by calling them as functions.

Use this option to run in batch processing mode.

If you use the > constructor to pipe to MATLAB, then the nodesktop option is used automatically.

MATLAB provides a command window-only interface in the desktop environment. On the Home tab, click Layout. Then, under Select Layout, select Command Window Only.


Start MATLAB without the JVM software. Features that require Java software (such as the desktop tools and graphics) are not supported.

Display Options


Disable the display of figure windows in MATLAB.


Do not display the splash screen during startup.


Start the JVM software without starting the MATLAB desktop.

Execute MATLAB Script or Function


-r statement

Execute the specified MATLAB statement, specified as a string or as the name of a MATLAB script or function. If statement is MATLAB code, enclose the string in double quotation marks. If statement is the name of a MATLAB function or script, do not specify the file extension and do not use quotation marks. Any required file must be on the MATLAB search path or in the startup folder.


To set the initial working folder to folder, type:

-sd folder

Example: -r "disp(['Current folder: ' pwd])"

Example: -r myscript

Set Initial Working Folder

The initial working folder is the current folder when MATLAB starts. For more information, see MATLAB Startup Folder.


-sd folder

Set the MATLAB startup folder to folder, specified as a string.

Example: matlab -sd "C:\work"


Set the MATLAB startup folder to the value specified by the Initial working folder option in the General Preferences panel.

Specify MATLAB Version


Start the version of MATLAB in the bin/arch/variant folder instead of the bin/arch folder, where:

  • arch is the system architecture, the value returned by the computer('arch') function

  • variant is a string representing a MATLAB version

Debugging Options


-logfile filename

Copy Command Window output, including error reports, into filename, specified as a string.

Example: -logfile output.log


Display, without starting MATLAB, the final values of the environment variables and arguments passed to the MATLAB executable. This option also displays other diagnostic information for use when working with a Technical Support Representative.


Display, without starting MATLAB, all environment variables and their values to standard output. If the exit status is not 0 on return, then the variables and values might not be correct.

-Ddebugger debugopts

Start MATLAB in debug mode. This option uses the debugger program name, debugger, specified as a string, for example, gdb, lldb, or dbx. You can specify the full path to the debugger. This option must be the first option in the matlab script.

Debugger program command-line options, debugopts, specified as a string of valid options for debugger. See your debugger documentation for details. Do not use any other matlab script options when using debugopts.

Do not add a space between D and debugger.

Example: -Dlldb

-jdb portnumber

Enable use of the Java debugger. The Java debugger uses the default portnumber value 4444 to communicate with MATLAB.

The port number is optional. However, to use the Java debugger while running multiple MATLAB sessions, you must specify a port number. The portnumber value must be an integer in the range 0–65535. The integer cannot be reserved or currently in use by another application on your system.

Use Single Computational Thread

By default, MATLAB uses the multithreading capabilities of the computer on which it is running.


Limit MATLAB to a single computational thread.

Disable Searching Custom Java Class Path


Disable use of javaclasspath.txt and javalibrarypath.txt files. For more information, see Specifying Java Startup Options.

Specify License File


-c license

Use the specified license file, license, specified as a string, a colon-separated list of license file names, or a port@host entry. For more information, see Understanding Network License Files (Installation, Licensing, and Activation).

Open Student Version



Open student version of MATLAB.

Help Options


Display startup options without starting MATLAB.


Same as -h option.


expand all

Move to the bin folder within the application package for MATLAB installed in a folder named MyMATLAB.

cd /Applications/MyMATLAB/

Preface the matlab script with ./ characters.

./matlab -nosplash

Start MATLAB R2015a from any Terminal folder by specifying the full path name. Assume MATLAB is installed in a folder named MyMATLAB.

matlab -nojvm -nodisplay -nosplash
matlab -r "disp(['Current folder: ' pwd])"

More About

expand all