Desktop Tools and Development Environment Previous page   Next Page

Startup Options

You can define startup options for MATLAB that instruct MATLAB to perform certain operations when you start it. There are two ways to specify startup options for MATLAB:

Using the Startup File for MATLAB, startup.m

At startup, MATLAB automatically executes the master M-file matlabrc.m and, if it exists, startup.m. The file matlabrc.m, which is in the local directory, is reserved for use by The MathWorks, and by the system manager 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 Handle Graphics® defaults. Creating a startup.m file with the line

addpath /home/me/mytools
cd /home/me/mytools

adds /home/me/mytools to your default search path and makes mytools the current directory upon startup.

Location of startup.m.   Place the startup.m file in the current startup directory, which is where MATLAB first looks for it. For more information, see Startup Directory for MATLAB. You can instead place it in $matlabroot/toolbox/local, which is the next place MATLAB looks for startup.m, where $matlabroot is the directory in which MATLAB is installed.

Adding Startup Options for Windows Platforms

You can add selected startup options (also called command flags or command line switches) to the target path for your Windows shortcut for MATLAB. Or you can add them to the matlab function when you start MATLAB in a DOS window. The process is described in the following topics:

Startup Options in Windows Shortcut.   To use startup options in the Windows shortcut for MATLAB, follow these steps:

  1. Right-click the MATLAB shortcut icon and select Properties from the context menu. The Properties dialog box for matlab.exe opens to the Shortcut pane.
  2. In the Target field, after the target path for matlab.exe, add the startup option. For example, adding /r filename runs the M-file filename after startup.
  3. Click OK.

This example adds /r results to the end of the file path, which instructs MATLAB to automatically run the file results after startup. The statement in the Target field might appear as

H:\Programs\matlab.exe /r results

Use only the filename, not the file extension or pathname. For example, MATLAB produces an error when you run

... matlab /r C:\results.m

Startup Options in DOS Window.   When you start MATLAB in a DOS window, include startup options after the matlab function.

This example adds the /r startup option to run multiple MATLAB commands after starting MATLAB in a DOS window:

matlab /r hf=figure;peaks;print(hf);exit

When MATLAB starts, it automatically creates a figure, runs peaks, prints the figure, and exits.

List of Startup Options for Windows Platforms.   Use these options in the target path of the Windows shortcut for MATLAB, or with the matlab function in a DOS window. The following table lists some commonly used startup options You can use a hyphen (-) instead of a slash (/), for example, -nosplash.For a complete list of the startup options for Windows platforms, see the reference page for the matlab (Windows) function.

Option
Description 
/c licensefile
Set LM_LICENSE_FILE to licensefile. It can have the form port@host.
/logfile logfilename
Automatically write output from MATLAB to the specified log file.
/minimize
Start MATLAB with the desktop minimized. Any desktop tools or documents that were undocked when MATLAB was last closed will not be minimized upon startup.
/nosplash
Start MATLAB without displaying the MATLAB splash screen.
/r MATLAB_file
Automatically run the specified MATLAB M-file, either commands supplied with MATLAB or your own M-files, immediately after MATLAB starts. This is also referred to as calling MATLAB in batch mode. Separate multiple commands with commas or semicolons (;). M-files must be on the MATLAB path or in the MATLAB startup directory. Do not include the pathname or a file extension.

Adding Startup Options for UNIX Platforms

Include startup options (also called command flags or command line switches) after the matlab startup command.

For example, to start MATLAB without the splash screen, type

matlab -nosplash

List of Startup Options for UNIX Platforms.   The following tables list some commonly used startup options.

For a complete list, see the matlab (UNIX) reference page.

Option
Description  
-h or -help
Display startup options (without starting MATLAB).
-logfile log
Automatically write output from MATLAB to the specified log file.
-nodesktop
Start MATLAB without bringing up the MATLAB desktop. Use this option to run without an X-window, for example, in VT100 mode, or in batch processing mode. Note that if you pipe to MATLAB using the > constructor, the nodesktop option is used automatically.
With nodesktop, you can still use most development environment tools by starting them via a function. For example, use commandhistory to open the Command History and helpbrowser to open the Help browser.
Do not use nodesktop to provide a command line interface. If you prefer a command line interface, select Desktop -> Desktop Layout -> Command Window Only.
-nojvm
Start MATLAB without loading the Java VM. This minimizes memory usage and improves initial startup speed, but restricts functionality. With nojvm, you cannot use the desktop, or any tools that require Java.
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 will remember that preference when you start it again, even if you use the -nojvm option.
-nosplash
Start MATLAB without displaying the splash screen during startup.
-r MATLAB_command
Automatically run the specified MATLAB M-file, either commands supplied with MATLAB or your own M-files, immediately after MATLAB starts. This is also referred to as calling MATLAB in batch mode. Separate multiple commands with commas or semicolons (;). M-files must be on the MATLAB path or in the MATLAB startup directory. Do not include the pathname or a file extension.


Previous page  Startup Directory for MATLAB Startup and Calling Java from MATLAB Next page

© 1994-2005 The MathWorks, Inc.