Documentation |
Start MATLAB program from Mac or Linux system prompt
matlab
matlab helpOption
matlab envDispOption
matlab archOption
matlab dispOption
matlab modeOption
matlab -c licensefile
matlab -debug
matlab -Ddebugger
options
matlab -jdb portnumber
matlab -logfile filename
matlab -mwvisual visualid
matlab -noFigureWindows
matlab -nosoftwareopengl
matlab -nosplash
matlab -nouserjavapath
matlab -r "command"
matlab -singleCompThread
matlab -softwareopengl
matlab is a Bourne shell script that starts the MATLAB program from a Mac or Linux^{®} system prompt. (In this document, the term matlab refers to this script; MATLAB refers to the program). Before actually initiating the execution of MATLAB, matlab configures the run-time environment by:
Determining the MATLAB root folder.
Determining the host machine architecture.
Processing any command-line options .
Reading the MATLAB startup file, .matlab7rc.sh.
Setting MATLAB environment variables.
There are two ways in which you can control the way the matlab script works:
By specifying command-line options.
By assigning values in the MATLAB startup file, .matlab7rc.sh.
Note: On Apple Macintosh platforms, the matlab script is located inside the MATLAB application package: /Applications/MATLAB_R2012b.app/bin/matlab To run the matlab command from Terminal, specify the full path, or cd to the bin folder within the application package and preface the command with ./ characters. For example: ./matlab -nojvm -nodisplay -nosplash -r "myfun(10,30)" |
Options that you can enter at the command line are as follows:
matlab helpOption displays information that matches the specified helpOption argument without starting MATLAB. helpOption can be any one of the keywords shown in the following table. Enter only one helpOption keyword in a matlab command.
Values for helpOption
Option | Description |
---|---|
-help | Display matlab command usage. |
-h | The same as -help. |
matlab envDispOption displays the values of environment variables passed to MATLAB or their values when exiting MATLAB. envDispOption can be either one of the options shown in the following table.
Values for envDispOption
Option | Description |
---|---|
-n | Display all the final values of the environment variables and arguments passed to the MATLAB executable as well as other diagnostic information. Does not start MATLAB. |
-e | Display all environment variables and their values before exiting. This argument must have been parsed before exiting for anything to be displayed. The last possible exiting point is just before the MATLAB image would have been executed and a status of 0 is returned. If the exit status is not 0 on return, then the variables and values might not be correct. Does not start MATLAB. |
matlab archOption starts MATLAB and assumes that you are running on the system architecture specified by arch, or using the MATLAB version specified by variant, or both. The values for the archOption argument are shown in the following table. Enter only one of these options in a matlab command.
Values for archOption
Option | Description |
---|---|
-arch | Run MATLAB assuming this architecture rather than the actual architecture of the machine you are using. Replace the term arch with a string representing a recognized system architecture. For example: matlab -glnx86 |
v=variant | Execute the version of MATLAB found in the folder bin/$ARCH/variant instead of bin/$ARCH. Replace the term variant with a string representing a MATLAB version. |
v=arch/variant | Execute the version of MATLAB found in the folder bin/arch/variant instead of bin/$ARCH. Replace the terms arch and variant with strings representing a specific architecture and MATLAB version. |
matlab dispOption starts MATLAB using one of the display options shown in the following table. Enter only one of these options in a matlab command.
Values for dispOption
Option | Description |
---|---|
-display xDisp | Send X commands to X Window Server display xDisp. This option supersedes the value of the DISPLAY environment variable. On Macintosh platforms, this option is ignored. |
-nodisplay | Start the Oracle^{®} JVM™ software, but do not start the MATLAB desktop. Do not display any X commands, and ignore the DISPLAY environment variable. On Macintosh platforms, start the JVM in headless mode, and prevent all windows from being displayed. |
matlab modeOption starts MATLAB without its usual desktop component. Enter only one of the options shown in the following table.
Values for modeOption
Option | Description |
---|---|
-desktop | Allow the MATLAB desktop to be started by a process without a controlling terminal. This is usually a required command-line argument when attempting to start MATLAB from a window manager menu or desktop icon. |
-nodesktop | Start MATLAB without bringing up the MATLAB desktop. The JVM software is started. To enter commands, use the current window in the operating system. Use this option to run in batch processing mode. If you pipe to MATLAB using the > constructor, the nodesktop option is used automatically. With nodesktop, MATLAB does not save statements to the Command History. With nodesktop, you can still use most development environment tools by starting them via a function. For example, use preferences to open the Preferences dialog box and doc to open the Help browser. Do not use nodesktop to provide a Command Window-only interface; instead, select Desktop > Desktop Layout > Command Window Only. |
-nojvm | Start MATLAB without the JVM software. To enter commands, use the current window. The MATLAB desktop does not open. MATLAB graphics and any tools that require Java^{®} software, such as the desktop tools, are not supported; MATLAB displays a warning when you try to use such functionality. |
matlab -c licensefile starts MATLAB using the specified license file. The licensefile argument can have the form port@host or it can be a colon-separated list of license filenames. This option causes the LM_LICENSE_FILE and MLM_LICENSE_FILE environment variables to be ignored.
matlab -debug starts MATLAB and displays debugging information that can be useful, especially for X based problems. Use this option only when working with a Technical Support Representative from The MathWorks, Inc.
matlab -Ddebugger options starts MATLAB in debug mode, using the named debugger (for example, dbx, gdb, xdb, cvd, lldb). A full path can be specified for debugger.
Notes for -Ddebugger Argument
The options argument can include only those options that follow the debugger name in the syntax of the actual debug command. For most debuggers, there is a limited number of such options. Use options that would normally be passed to the MATLAB executable as parameters of a command inside the debugger (like run). Do not use options when running the matlab matlab.
If any other matlab command options are placed before the -Ddebugger argument, they will be handled as if they were part of the options after the -Ddebugger argument and are treated as illegal options by most debuggers. The MATLAB_DEBUG environment variable is set to the filename part of the debugger argument.
To customize your debugging session, use a startup file. See your debugger documentation for details.
For certain debuggers like gdb, the SHELL environment variable is always set to /bin/sh.
matlab -jdb portnumber starts MATLAB, enabling use of the Java debugger. If you specify a port number, the Java debugger uses that port to communicate with MATLAB. You can specify any port number in the range 0-65535 that is not reserved or currently in use by another application on your system. By default, MATLAB uses port 4444. If you are running multiple MATLAB sessions and want to use the Java debugger, be sure to specify a port number.
matlab -logfile filename starts MATLAB and makes a copy of any output to the Command Window in file log. The output includes all crash reports.
matlab -mwvisual visualid starts MATLAB and uses visualid as the default X visual for figure windows. visualid is a hexadecimal number that can be found using xdpyinfo.
matlab -noFigureWindows starts MATLAB, but disables the display of any figure windows in MATLAB.
matlab -nosoftwareopengl disables auto-selection of software OpenGL^{®} when a graphics driver with known issues is detected. See -softwareopengl option. Not available on Mac platforms.
matlab -nosplash starts MATLAB but does not display the splash screen during startup.
matlab -nouserjavapath disables javaclasspath.txt and javalibrarypath.txt files.
matlab -r "command" starts MATLAB and executes the specified MATLAB command. Include the command in double quotation marks ("command"). If command is the name of a MATLAB function or script, do not specify the file extension. To separate multiple statements, use semicolons or commas.
matlab -singleCompThread limits MATLAB to a single computational thread. By default, MATLAB uses the multithreading capabilities of the computer on which it is running.
matlab -softwareopengl forces MATLAB to start with software OpenGL libraries. See -nosoftwareopengl option. Not available on Mac platforms.
The .matlab7rc.sh shell script contains definitions for a number of variables that the matlab script uses. These variables are defined within the matlab script, but can be redefined in .matlab7rc.sh. When invoked, matlab looks for the first occurrence of .matlab7rc.sh in the current folder, in the home folder ($HOME), and in the matlabroot/bin folder, where the template version of .matlab7rc.sh is located.
You can edit the template file to redefine information used by the matlab script. If you do not want your changes applied system-wide, copy the edited version of the script to your current or home folder. Ensure that you edit the section that applies to your machine architecture.
The following table lists the variables defined in the.matlab7rc.sh file. See the comments in the .matlab7rc.sh file for more information about these variables.
Variable Options for Startup File
Variable | Definition and Standard Assignment Behavior |
---|---|
ARCH | The machine architecture. The value ARCH passed with the -arch or -arch/ext argument to the script is tried first, then the value of the environment variable MATLAB_ARCH is tried next, and finally it is computed. The first one that gives a valid architecture is used. |
DISPLAY | Linux platforms only. The hostname 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 on Linux platforms. DYLD_LIBRARY_PATH on Macintosh platforms. | Final Load library path. The name LD_LIBRARY_PATH is platform-dependent. 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. |
LM_LICENSE_FILE | The FLEX lm license variable. The license file value passed with the -c argument to the script is used; otherwise it is the value set in .matlab7rc.sh. In general, the final value is a colon-separated list of license files and/or port@host entries. The shipping .matlab7rc.sh file starts out the value by prepending LM_LICENSE_FILE in the environment to a default license.file. Later in the matlab script, if the -c option is not used, the matlabroot/etc folder is searched for the files that start with license.dat.DEMO. These files are assumed to contain demo licenses and are added automatically to the end of the current list. |
MATLAB | The MATLAB root folder. The default computed by the script is used unless MATLABdefault is reset in .matlab7rc.sh. Currently MATLABdefault is not reset in the shipping .matlab7rc.sh. |
MATLAB_DEBUG | Normally set to the name of the debugger. The -Ddebugger argument passed to the script sets this variable. Otherwise, a nonempty value in the environment is used. |
MATLAB_JAVA | The path to the root of the Java Runtime Environment. The default set in the script is used unless MATLAB_JAVA is already set. Any nonempty value from .matlab7rc.sh is used first, then any nonempty value from the environment. Currently there is no value set in the shipping .matlab67rc.sh, so that environment alone is used. |
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. You can add subfolders of userpath to theMATLAB search path upon startup. 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, then 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 and also 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. |
XAPPLRESDIR | The X application resource folder (Linux systems only). A nonempty value in the environment is used first unless XAPPLRESDIR is reset in .matlab7rc.sh. |
XKEYSYMDB | The X keysym database file (Linux systems only). A nonempty value in the environment is used first unless XKEYSYMDB is reset in .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). The MATLAB variable is then used to locate all files within the MATLAB folder tree.
You can change the definition of MATLAB if, for example, you want to run a different version of MATLAB or if, for some reason, the path determined by the matlab script is not correct. (This can happen when your system uses certain types of automounting schemes.)