Documentation

matlab (Linux)

Start MATLAB program from Linux system prompt

Syntax

  • matlab
  • matlab option1 ... optionN

Description

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

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

Alternatively, assign startup options in the MATLAB .matlab7rc.sh Startup File. Modifying the .matlab7rc.sh file defines startup options every time you start MATLAB.

Input Arguments

collapse all

option1 ... optionN — One or more startup optionsstrings

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

Mode Options

OptionResult
-desktop

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

-nodesktop

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 pipe to MATLAB using the > constructor, the nodesktop option is used automatically.

Do not use nodesktop to provide a Command-Window-only interface. Instead, in the Environment section on the Home tab, click Layout. Then, under Select Layout, select Command Window Only.

-nojvm

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

Display Options

OptionResult
-noFigureWindows

Disable the display of figure windows in MATLAB.

-nosplash

Do not display the splash screen during startup.

-nodisplay

Start the JVM software without starting the MATLAB desktop. This option does not display X commands. It overrides the DISPLAY environment variable.

-display xDisp

Send X commands to X Window Server display xDisp. This option overrides the DISPLAY environment variable.

Execute MATLAB Script or Function

OptionResult

-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 with 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.

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

Example: -r myscript

Specify MATLAB Version

OptionResult
v=variant

Start the version of MATLAB in the bin/variant folder.

Debugging Options

OptionResult

-logfile filename

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

Example: -logfile output.log

-n

Display, without starting MATLAB, 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.

-e

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 command.

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 command options when using debugopts.

Do not add a space between D and debugger.

Example: -Dgdb

-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.

-debug

Display information for debugging X-based problems. Use this option only when working with a Technical Support Representative from MathWorks, Inc.

Use Single Computational Thread

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

OptionResult
-singleCompThread

Limit MATLAB to a single computational thread.

Disable Searching Custom Java Class Path

OptionResult
-nouserjavapath

Disable use of javaclasspath.txt and javalibrarypath.txt files. For more information, see java.opts Files.

OpenGL Library Options

These options control the use of software OpenGL® libraries when MATLAB detects a graphics driver with known issues. For more information, see Features with OpenGL Requirements.

OptionResult
-softwareopengl

Force MATLAB to start with software OpenGL libraries.

-nosoftwareopengl

Disable auto-selection of OpenGL software.

Specify License File

OptionResult

-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 License Files in License Management.

Help Options

OptionResult
-h

Display startup options without starting MATLAB.

-help

Same as -h option.

Examples

Start MATLAB Without Desktop or JVM

matlab -nojvm -nodisplay -nosplash

Display Current Folder at Startup

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

Definitions

.matlab7rc.sh Startup File

The .matlab7rc.sh shell script contains variable definitions used by the matlab script.

Use the .matlab7rc.sh file to redefine variables defined in the matlab script. matlab looks for the first occurrence of .matlab7rc.sh in the:

  • Current folder

  • Home folder ($HOME)

  • matlabroot/bin folder

To edit the .matlab7rc.sh file, use the template located in the matlabroot/bin folder.

This table lists the variables. For more information, see the comments in the .matlab7rc.sh file.

Variable

Definition and Standard Assignment Behavior

ARCH

The machine architecture.

MATLAB checks for a valid architecture in this order:

  • The value ARCH passed with the -arch or -arch/ext argument to the script.

  • The value of the environment variable MATLAB_ARCH.

DISPLAY

The host name of the X Window display MATLAB uses for output.

The value of Xdisplay passed with the -display argument to the script is used; otherwise, the value in the environment is used. MATLAB ignores DISPLAY if the -nodisplay argument is passed.

LD_LIBRARY_PATH

Final Load library path.

The final value is normally a colon-separated list of four sublists, each of which could be empty. The first sublist is defined in .matlab7rc.sh as LDPATH_PREFIX. The second sublist is computed in the script and includes folders inside the MATLAB root folder and relevant Java folders. The third sublist contains any nonempty value of LD_LIBRARY_PATH from the environment possibly augmented in .matlab7rc.sh. The final sublist is defined in .matlab7rc.sh as LDPATH_SUFFIX.

MATLAB

The MATLAB root folder.

MATLAB uses the default computed by the script unless MATLABdefault is reset in .matlab7rc.sh.

Currently MATLABdefault is not reset in the shipping .matlab7rc.sh.

MATLABPATH

The MATLAB search path.

The final value is a colon-separated list with the MATLABPATH from the environment prepended to a list of computed defaults. At startup, you can add subfolders of userpath to the MATLAB search path. See userpath for details.

SHELL

The shell to use when the "!" or unix command is issued in MATLAB. This value is taken from the environment, unless SHELL is reset in .matlab7rc.sh.

Another environment variable called MATLAB_SHELL takes precedence over SHELL. MATLAB checks internally for MATLAB_SHELL first and, if empty or not defined, it checks SHELL. If SHELL is also empty or not defined, MATLAB uses /bin/sh. Use an absolute path for the value of MATLAB_SHELL, that is, /bin/sh, not simply sh.

Currently, the shipping .matlab7rc.sh file does not reset SHELL. Also, this file does not reference or set MATLAB_SHELL.

TOOLBOX

Path of the toolbox folder.

A nonempty value in the environment is used first. Otherwise, matlabroot/toolbox, computed by the script, is used unless TOOLBOX is reset in .matlab7rc.sh. Currently TOOLBOX is not reset in the shipping .matlab7rc.sh.

The matlab script determines the path of the MATLAB root folder by looking up the folder tree from the matlabroot/bin folder (where the matlab script is located). MATLAB use the MATLAB variable to locate all files within the MATLAB folder tree.

You can change the definition of MATLAB. For example, change the definition if you want to run a different version of MATLAB. Or change the definition if your system uses certain types of automounting schemes and the path determined by the matlab script is not correct.

Was this topic helpful?