Quantcast

Documentation Center

  • Trial Software
  • Product Updates

Startup Options

Specifying MATLAB Startup Options

Specifying Startup Options from Command Line

You can specify startup options (also called command flags or command-line switches) that instruct the MATLAB® program to perform certain operations when you start it. On all platforms, you specify the options as arguments to the matlab command when you start at the operating system prompt. For example, the following starts MATLAB and suppresses the display of the splash screen.

matlab -nosplash

On Windows® platforms, you can precede a startup option with either a hyphen (-) or a slash (/). For example, -nosplash and /nosplash are equivalent.

Specifying Startup Options in Shortcut on Windows Systems

You can add selected startup options (also called command flags or switches for the command line) to the target path for your shortcut on the Windows platform for MATLAB. For more information about the options, see Commonly Used Startup Options.

To use startup options for the MATLAB shortcut icon on a Windows platform, follow these steps:

  1. Right-click the shortcut icon for MATLAB and select Properties from the context menu. The Properties dialog box for MATLAB opens to the Shortcut pane.

  2. In the Target field, after the target path for matlab.exe, add the startup option, and click OK. For example, adding -r "filename" runs the MATLAB code file filename after startup.

This example instructs MATLAB to automatically run the file results after startup, where results.m is in the startup folder or on the search path for MATLAB. The statement in the Target field might appear as:

C:\Program Files\MATLAB\R2010b\bin\matlab.exe -r "results"

Include the statement in double quotation marks ("statement"). Use only the file name, not the file extension or path. For example, MATLAB produces an error when you run

... matlab.exe -r "D:\results.m"

Use semicolons or commas to separate multiple statements. This example changes the format to short, and then runs the MATLAB code file results:

... matlab.exe -r "format('short');results"

Separate multiple options with spaces. This example starts MATLAB without displaying the splash screen, and then runs the MATLAB code file results:

... matlab.exe -nosplash -r "results"

Specifying Startup Options in MATLAB Startup File

At startup, MATLAB automatically executes the file matlabrc.m and, if it exists, startup.m. The file matlabrc.m, which is in the matlabroot/toolbox/local folder, is reserved for use by MathWorks® and by the system administrator on multiuser systems.

The file startup.m is for you to specify startup options. For example, you can modify the default search path, predefine variables in your workspace, or define defaults for Handle Graphics® objects. Use the following statements in a startup.m file to add the specified folder, /home/username/mytools, to the search path, and to change the current folder to mytools upon startup.

addpath /home/username/mytools
cd /home/username/mytools

Place the startup.m file in the default or current startup folder, which is where MATLAB first looks for it. For more information, see MATLAB Startup Folder.

Commonly Used Startup Options

The following table provides a list of some commonly used startup options for both Windows and UNIX® platforms. For more information, including a complete list of startup options, see the matlab (Windows) or the matlab (UNIX) documentation.

Platform

Option

Description

All

-c licensefile

Set LM_LICENSE_FILE to licensefile. It can have the form port@host.

All

-h or -help

Display startup options (without starting MATLAB).

All

-logfile "logfilename"

Automatically write output from MATLAB to the specified log file.

Windows platforms

-minimize

Start MATLAB with the desktop minimized. Any desktop tools or documents that were undocked when MATLAB was last closed are not minimized at startup.

UNIX platforms

-nojvm

Start MATLAB without loading the JVM™ software. This minimizes memory usage and improves initial startup speed, but restricts functionality. With nojvm, you cannot use the desktop, figures, or any tools that require Java® software.

For example, you cannot set preferences if you start MATLAB with the -nojvm option. However, you can start MATLAB once without the -nojvm option, set the preference, and quit MATLAB. MATLAB remembers that preference when you start it again, even if you use the -nojvm option.

All

-nosplash

Start MATLAB without displaying its splash screen.

All

-r "statement"

Automatically run the specified statement immediately after MATLAB starts. This is sometimes referred to as calling MATLAB in batch mode. Files you run must be in the startup folder for MATLAB or on the search path. Do not include path names or file extensions. Enclose the statement in double quotation marks ("statement"). To separate multiple statements, use semicolons or commas.

All

-singleCompThread

Limit MATLAB to a single computational thread. By default, Windows uses the multithreading capabilities of the computer on which it is running.

Passing Perl Variables on Startup

You can pass Perl variables to MATLAB on startup by using the -r option of the matlab function. For example, assume a MATLAB function test that takes one input variable:

function test(x)

To pass a Perl variable instead of a constant as the input parameter, follow these steps. This command starts MATLAB and runs test with the input argument 10.

  1. Create a Perl script such as

     #!/usr/local/bin/perl
     $val = 10; 
     system('matlab -r "test(' . ${val} . ')"');
  2. Invoke the Perl script at the prompt using a Perl interpreter.

For more information, see the -r option in the matlab (Windows) or matlab (UNIX) documentation.

Startup and Calling Java Software from MATLAB

When MATLAB starts, it constructs the class path for Java software using librarypath.txt as well as classpath.txt. If you call Java software from MATLAB, see more about this in The Java Class Path and Locating Native Method Libraries.

More About

Was this topic helpful?