Startup Options

About Startup Options

You can define startup options that instruct the MATLAB® program to perform certain operations when you start it. On Windows® and Macintosh® platforms, you can use a GUI to specify the options. On all platforms, you can specify these options using a startup file (startup.m), or in conjunction with the matlab startup function.

Specifying Startup Options for Windows® Platforms

You can add selected startup options (also called command flags or switches for the command line) to the target path for your shortcut in the Windows environment for MATLAB. Or you can add them to the command line when you start MATLAB in a DOS window. For more information about the options, seeCommonly Used Startup Options.

On Windows platforms, a startup option is preceded by either a hyphen (-) or a slash (/). For example, -nosplash and /nosplash are equivalent ways of specifying the nosplash option for users on Windows platforms.

Startup Options for a Shortcut in Windows® Environment

To use startup options for the MATLAB shortcut icon in a Windows environment, 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 M-file filename after startup.

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

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

Include the statement in double quotation marks ("statement"). Use only the filename, not the file extension or pathname. 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 M-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 M-file results:

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

Startup Options in a DOS Window

When you start MATLAB in a DOS window, include startup options after the matlab command.

This example uses the nosplash startup option to start MATLAB without the splash screen, and adds the -r option to run the results function located in the startup directory, after starting MATLAB in a DOS window:

matlab -nosplash -r "results"

Specifying Startup Options for UNIX® Platforms

Include startup options (also called command flags or command line switches) after the matlab command. For more information about the options, seeCommonly Used Startup Options. On UNIX® platforms, a startup option is preceded by a hyphen (-). For example, to start MATLAB without the splash screen, type

matlab -nosplash

See also the userpath function.

Specifying Startup Options for Macintosh® Platforms

On Macintosh platforms, use the Start MATLAB Settings dialog box to specify startup options and then start MATLAB.

The dialog box appears the first time you start a new version of MATLAB. You can access the dialog box at any time by double-clicking the Start MATLAB Settings application (.smat extension) in the Finder, located in the same directory as the MATLAB application.

Image of the Start MATLAB Settings dialog box.

Follow these steps to specify options in the dialog box:

  1. Either select one of the standard settings, or create a new setting.

    You can change the options in any of the three standard settings provided, Xterm, Terminal, and MATLAB Desktop, or add your own settings. For example, if you always start MATLAB from an xterm, but you do not use the default startup directory, use the Xterm setting provided, but modify its Current directory value. If you regularly start MATLAB from the desktop, but use different options depending on the project you are working on, create and name a new setting for each project by using the + (add setting) button.

  2. For the selected setting, specify the Start MATLAB from option, which is how you will interact with MATLAB, either using MATLAB desktop or a shell. Selecting Shell is equivalent to using the -nodesktop startup option when you start MATLAB with the matlab command; MATLAB starts without the desktop and you then interact with MATLAB via the shell.

  3. Specify the startup directory for MATLAB by using the Current directory options. You can accept the default, the User work folder, which is usually /home/username/Documents/MATLAB, or you can type a value or browse to specify a different startup directory.

  4. If you want MATLAB to automatically run a specified statement immediately after startup, enter the statement in the Run command field. For more information about how to specify statements, see the r option in Commonly Used Startup Options.

  5. To run MATLAB without the Sun Microsystems™ Java™ software, clear the Use Java check box. For more information, see the nojvm option in Commonly Used Startup Options.

  6. To automatically write output from MATLAB to a log file, select the Log to check box, and use the default filename or specify a different log filename.

  7. After setting the options, you can start MATLAB using those options—click the Start MATLAB button.

    You can also drag one of the settings to the desktop or a location in the Finder, which creates a MATLAB icon in that location, having the name of that setting. Double-click the icon to start MATLAB using the options specified for that setting. You can also create the icon by selecting File > Export.

In Start MATLAB Settings, you can also access tools from the Diagnostics menu to help you resolve startup problems.

You can specify these and other startup options for Macintosh platforms with the matlab command, as described at Specifying Startup Options for UNIX® Platforms.

Specifying Startup Options Using the Startup File for the MATLAB® Program, 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 matlabroot/toolbox/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 defaults for Handle Graphics® objects. Creating a startup.m file with the lines

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

adds /home/username/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 default or current startup directory, which is where MATLAB first looks for it. For more information, see Startup Directory for the MATLAB® Program.

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) reference page or the matlab (UNIX) reference page.

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.

UNIX platforms

-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 preferences to open the Preferences dialog box 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.

Windows platforms

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

UNIX platforms

-nojvm

Start MATLAB without loading the Sun MicrosystemsJava JVM™ software. 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 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 directory for MATLAB or on the search path. Do not include pathnames or file extensions. Enclose the statement in double quotation marks ("statement"). Use semicolons or commas to separate multiple statements

  


 © 1984-2008- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS