Skip to Main Content Skip to Search
Product Documentation

Starting and Quitting the MATLAB Program

Starting the MATLAB Program on Windows Platforms

There are several ways to start the MATLAB program on a Microsoft® Windows® platform:

After starting MATLAB, the desktop opens. Desktop components that were open when you last shut down MATLAB will be opened on startup. For more information, see Adjust Desktop Appearance. You can specify other startup options, such the current folder upon startup—for more information, see Startup Options and Startup Folder for the MATLAB Program.

If you have trouble starting MATLAB, see troubleshooting information in the Troubleshooting.

Associating Files with MATLAB on Windows Platforms

When you install MATLAB software on Windows platforms, the installer sets up associations between certain file types and MathWorks products. When you double-click a particular file type, identified by its file extension, Windows starts MATLAB and opens the file in the appropriate tool. The following table lists some of the file extensions the installer associates with MathWorks products and the behavior that results from this association. To learn how to change this behavior, see Managing File Associations for MATLAB on Windows Systems.

File Extension and Resulting Action

File ExtensionResult
.figOpens file in figure window
.mOpens file in Editor
.matOpens Import Wizard to load the data into the MATLAB workspace.
.mdlOpens file in a Simulink® model window
.mex[a] Displays icon for MATLAB in Windows Explorer tool
.pDisplays icon for MATLAB in Windows Explorer tool

[a] MEX-file extensions are platform specific. See Using Binary MEX-Files.

File associations for the Windows Explorer tool do not affect what happens when you open one of these file types from within MATLAB. MATLAB acts on the file using the MATLAB tool associated with that file type. For example, even if your system associates .mat files with the Access™ application, when you open a MAT-file from within MATLAB, it opens the Import Wizard to load the data.

Managing File Associations for MATLAB on Windows Systems.  You can associate any file types with MATLAB on computers running the Windows operating system. For example, you can associate the .xml extension with MATLAB so that when you double-click an XML file, it opens in the MATLAB Editor.

Occasionally, another program may already own the association with a particular file type. For example, the Microsoft Access program might own the association with files having a .mat extension. To reset this file association, use the Windows Default Programs control panel.

  1. Click the Windows Start menu.

  2. Select Control Panel.

  3. In the Control Panel window, select Default Programs.

  4. In the Default Programs window, select Associate a file type or protocol with a program.

  5. In the Set Associations window, select a file name extension to view which program currently opens it by default. In this example, select .mat.

  6. To change the default association, click Change Program. This opens the Open with dialog box which lists other programs that might be recommended for this file extension. If you don't see MATLAB in the list, click Browse and navigate to the MATLAB installation folder. Open the folder for the version of MATLAB that you want to associate with this file extension and navigate to the /bin/arch folder, where arch is platform-specific, such as win64. Select the MATLAB executable, MATLAB.exe and click OK. You create file associations with particular versions of MATLAB.

  7. Click Close to close the Set Associations dialog box.

After associating a file type with MATLAB, you can open other applications that have the same extension via the context menu. For example, if you want to open a MAT-file with the Access application, right-click myfile.mat, and from the context menu, select Open With. The Access application should be one of the options.

Speeding Up MATLAB Start Up on Windows Systems

On Windows systems, the MathWorks Installer installs and configures a utility program that can speed-up MATLAB startup, called the MATLAB Startup Accelerator. For information about this program, including information about how to modify the configuration, see License Administration Guide on the MathWorks Web site.

Starting the MATLAB Program on Linux Platforms

To start the MATLAB program on Linux® platforms, type matlab at the operating system prompt.

If you did not set up symbolic links in the installation procedure, you must enter the full path name, matlabroot/bin/arch, where matlabroot is the name of the folder in which you installed MATLAB and arch is an architecture-specific subfolder, such as glnxa64.

After starting MATLAB, the desktop opens. Desktop components that were open when you last shut down MATLAB will be opened on startup. For more information, see Adjust Desktop Appearance.

If the DISPLAY environment variable is not set or is invalid, the desktop will not display. If you have trouble starting MATLAB, see troubleshooting information in the Troubleshooting.

You can specify the current folder upon startup as well as other options—for more information, see and Startup Options.

Starting the MATLAB Program on Macintosh Platforms

There are several ways to start the MATLAB program on Macintosh® computers:

After starting MATLAB, the desktop opens. Desktop components that were open when you last shut down MATLAB will be opened on startup. For more information, see Adjust Desktop Appearance. If the DISPLAY environment variable is not set or is invalid, the desktop will not display.

If MATLAB fails to start due to a problem with required system components such as X11 or Sun Microsystems™ Java™ software, diagnostics run automatically and advise you of the problem, along with suggestions to correct it.

If you have trouble starting MATLAB, see troubleshooting information in the Troubleshooting.

You can specify the current folder upon startup as well as other options—for more information, see Startup Folder for the MATLAB Program and Startup Options.

Limitation

On Macintosh platforms, if you run MATLAB remotely, for example using rlogin, you must run with nodisplay, noawt, and nojvm startup options—for more information, see Startup Options.

Quitting the MATLAB Program

Ways to Quit the MATLAB Program

To quit the MATLAB program at any time, do one of the following:

MATLAB closes after

Confirm Quitting the MATLAB Program

To set a preference that displays a confirmation dialog box when you quit MATLAB, select File > Preferences > General > Confirmation Dialogs, select the Confirm before quitting check box, and click OK. MATLAB then displays the following dialog box when you quit.

Image of Exit confirmation dialog box .

For more information, see Confirmation Dialogs Preferences.

You can also display your own quitting confirmation dialog box using a finish.m script, as described in the following section.

Running a Script When Quitting the MATLAB Program

When MATLAB quits, it runs the script finish.m, if finish.m exists in the current folder or anywhere on the search path. You create the file finish.m. It contains statements to run when MATLAB terminates, such as saving the workspace or displaying a confirmation dialog box. There are two sample files in matlabroot/toolbox/local that you can use as the basis for your own finish.m file:

For more information, see the finish reference page.

Abnormal Termination

When the MATLAB Program Terminates Unexpectedly.  In the event MATLAB experiences a segmentation violation (segv) or other serious problem, the MATLAB System Error dialog box opens to notify you about the problem. When this occurs, the internal state of MATLAB is unreliable and not suitable for further use. You should exit as soon as possible and then restart. However, you might want to first try to save your work in progress.

To exit and restart without trying to save your work, follow these steps:

  1. If you want to view the stack trace for the problem, click Details.

  2. Click Close to terminate MATLAB.

  3. Restart MATLAB. If the Error Log Reporter dialog box opens, select the option to send a report to MathWorks.

To try to save your work in progress before exiting and restarting MATLAB, follow these steps:

  1. If you want to view the stack trace for the problem, click Details.

  2. Click Attempt to Continue. MATLAB tries to return to the Command Window or tool you were using.

    The Command Window displays the message Please exit and restart MATLAB to the left of the prompt, which reminds you to discontinue use.

  3. From the Command Window or tool, try to save the workspace and unsaved files.

      Caution   Because the internal state of MATLAB might be corrupted, do not save existing files to the same file name. Instead, specify a new file name. The information in the new file might be corrupted or incomplete.

  4. Exit MATLAB immediately after saving because any further usage would be unreliable.

  5. Restart MATLAB. If the Error Log Reporter dialog box opens, select the option to send a report to MathWorks.

Error Log Reporting.  Upon startup, if MATLAB detects an error log generated by a serious problem during the previous session, an Error Log Reporter prompts you to e-mail the log to MathWorks for analysis. The error log contains the stack trace and information about the MATLAB software configuration. If the problem occurs repeatedly, make note of what seems to cause it, look for information about it in the MathWorks Bug Reports database, and if the problem is reproducible, submit a Service Request via http://www.mathworks.com/support/contact_us/ts/help_request_1.html.

Emailing Error Log Reports.  

There are some situations where the Error Log Reporter will not open, for example, when you start MATLAB with a -r option or run in deployed mode. It also will not open if you selected the option to never send error reports the last time the Error Log Reporter opened. If you experience abnormal termination but do not see the Error Log Reporter on subsequent startups, you can instead email the reports.

Send email to segv@mathworks.com with this file attached: C:\Temp\matlab_crash_dump.####. After you send the log file, delete it or move it to another location. If you do not delete the log file, the Error Log Reporter can detect it on the next startup and prompt you to send it, even though you already emailed it.

Recovering Data After an Abnormal Termination.  If MATLAB terminates unexpectedly, you might lose information. After you start MATLAB again, you can try these suggestions to recover some of the information.

Some of the above suggestions refer to actions you might have needed to take during the session when MATLAB terminated. If you did not take those actions, consider regularly performing them to help you recover from any future abnormal terminations you might experience.


[a] MEX-file extensions are platform specific. See Using Binary MEX-Files.

  


Recommended Products

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.

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