matlab (Windows)
Start MATLAB program from Windows system prompt
Description
matlab
starts the MATLAB® program from the Microsoft®
Windows® system prompt. In this topic the term matlab
refers to the command you type, and MATLAB refers to the program.
The matlab
command:
Determines the MATLAB root folder, the value returned by the
matlabroot
function.Processes command-line options and passes other options to MATLAB.
To capture the exit code, start MATLAB with the -wait
option.
matlab
starts
MATLAB with the specified startup options.option1 ... optionN
Input Arguments
One or more startup options, specified as strings corresponding to valid startup options from the following tables.
Mode Options
Option | Result |
---|---|
-nojvm | Start MATLAB without allowing the JVM® software to be loaded in the session. Features that require Java® software are not supported. |
Display Options
Option | Result |
---|---|
-noFigureWindows | Disable the display of figure windows in MATLAB. |
Set Initial Working Folder
The initial working folder is the current folder when MATLAB starts. For more information, see MATLAB Startup Folder.
Option | Result |
---|---|
| Set the MATLAB folder to Example: |
| Set the MATLAB folder to the value specified by the Initial working folder setting, located in the General Settings page of the Settings window. |
Debugging Options
Option | Result |
---|---|
| Copy Command Window output, including error log
reports, in to Example:
|
| Enable use of the Java debugger. The Java debugger uses the default
The port number is
optional. However, to use the Java debugger while running multiple
MATLAB sessions, you must provide a port
number. The |
Execute MATLAB Script or Function
Option | Result |
---|---|
| Execute MATLAB script, statement, or function non-interactively. MATLAB:
Use the
If you run code that creates dialog boxes that require user input, MATLAB throws an error. To test
if a session of MATLAB is running in batch mode, call the
Example: |
| Execute the MATLAB
Note To set the initial working folder, use the
Example: Example:
|
Use Single Computational Thread
By default, MATLAB uses the multithreading capabilities of the computer on which it is running.
Option | Result |
---|---|
-singleCompThread | Limit MATLAB to a single computational thread. This option is for numerical computations only. |
Disable Searching Custom Java Class Path
Option | Result |
---|---|
-nouserjavapath | Disable use of
|
COM Server Options
Option | Result |
---|---|
| Start MATLAB as a Component Object Model (COM) Automation server. MATLAB does not display the splash screen and minimizes the window. Use for a single call to MATLAB. |
| Register MATLAB as a COM server in the Windows registry. You must have administrator privileges to change the Windows registry. Based on your User Account Control (UAC) settings, you might need to right-click a Windows Command Prompt and select Run as administrator. If that option is not available, contact your system administrator. Alternatively, you can register MATLAB from the MATLAB command prompt. Type: regmatlabserver For
more information, see Register MATLAB as COM Server and
|
| Remove MATLAB COM server entries from the registry. |
Wait for MATLAB to Terminate
By default, when you call the matlab
command from a
script, the command starts MATLAB and then immediately executes the next statements in the
script. The -wait
option pauses the script until
MATLAB terminates.
Option | Result |
---|---|
| Use in a script to process the results from MATLAB. Calling MATLAB with this option blocks the script from continuing until the results are generated. |
Specify License File
For more information, see Update or Modify Network License Files.
Option | Result |
---|---|
| Use the License File,
Example:
|
Help Options
Option | Result |
---|---|
-h | Display options without starting MATLAB. |
-help | Same as |
-? | Same as |
Examples
matlab -logfile output.log
To return an exit status on the command line, start
MATLAB with the -wait
option.
From the operating system prompt, type:
matlab -wait
Tips
To add folders to the MATLAB search path at startup, set the
MATLABPATH
environment variable before running thematlab
command. For more information, see Add Folders to the MATLAB Search Path at Startup.
Version History
If you start MATLAB using the matlab
function with the
-nojvm
startup option, desktop tools and graphics appear as
expected. In previous releases, desktop tools and graphics were not supported when
MATLAB was started using the -nojvm
startup option.
To prevent desktop tools and graphics from appearing, use the
-nodisplay
or -nodesktop
options. For
example:
matlab -nojvm -nodisplay
The matlab
command -nosplash
startup
option is no longer supported. If you specify the -nosplash
option at startup, MATLAB ignores the option. Previously, you could use the
-nosplash
startup option to suppress the display of the
splash screen.
If you use the -batch
option and run code that creates dialog
boxes that require user input, MATLAB throws an error. The exception is if you create the dialog box in a
test created using the app testing framework, such as
matlab.uitest.TestCase.chooseDialog
, in which case the code
runs without an error.
If you specify any of the following OpenGL® startup options, MATLAB issues a warning and the option has no effect.
-softwareopengl
-nosoftwareopengl
-softwareopenglmesa
-noopengl
This change was announced in R2022a.
To start MATLAB non-interactively, use the -batch
option. To start
MATLAB interactively, use the -r
option.
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: United States.
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)