Preferences

Set Preferences for MATLAB

MATLAB® provides various options called preferences for customizing MATLAB. To access and set preferences:

  1. On the Home tab, in the Environment section, click Preferences.

  2. From the left pane of the Preferences dialog box, select a tool, product, or an entry revealed when you click an arrow preceding a tool or product name.

  3. Change settings in the right pane of the Preferences dialog box.

  4. Click Apply or OK.

Preferences take effect immediately. They remain persistent across sessions of MATLAB.

Most preferences are not available in MATLAB Online™.

Function Alternative

You can open the Preferences dialog box using the preferences function.

You also can access and set some MATLAB options programmatically using settings. For more information, see Access and Modify Settings.

Where MATLAB Stores Preferences

MATLAB and other MathWorks® products store their preferences in the preferences folder. To see the full path for the preferences folder type prefdir in the MATLAB Command Window. The name of the preferences folder matches the name of the release. For instance, for MATLAB R2016b, the name of the preferences folder is R2016b.

On macOS and iOS, the folder might be in a hidden folder. If so, to access the hidden folder:

  1. In the Apple macOS Finder tool, select Go > Go to Folder.

  2. In the resulting dialog box, type the path returned by prefdir, and then press Enter.

You must have write access to the preferences folder. Otherwise, MATLAB generates an error in the Command Window when you try to change preferences. MATLAB also can generate an error if the preferences folder is hidden.

Temporary Preferences Folder

In some situations, if MATLAB is unable to create or use the preferences folder when starting up, it creates a temporary preferences folder. If a preferences folder exists for a previous release, MATLAB copies the preference files from that release to the temporary preferences folder. Otherwise, MATLAB creates the default preference files for the current release. MATLAB continues to use the temporary preferences folder until the issue is resolved.

If you make changes to preferences while MATLAB is using the temporary preferences folder, the preferences persist across sessions. Once the issue preventing MATLAB to access the preferences folder is resolved though, MATLAB copies the preference files from the previous release or creates the default preference files for the current release. Any changes made to the preferences while using the temporary preference folder are lost.

Each version of MATLAB can have a temporary preferences folder. MATLAB does not migrate preferences from the temporary preferences folder across releases.

Effects of Installation and Deinstallation on the Preferences Folder

Installing MATLAB has no effect on the preferences folder. That is, MATLAB creates, checks, copies, and writes to the preferences folder when you start up MATLAB, not when you install it. When you uninstall MATLAB, there is an option in the uninstaller to remove the preferences folder. However, this option is not selected by default.

Preferences MATLAB Uses When Multiple Releases Are Installed

The files in the preferences folder that MATLAB uses depends on the version of MATLAB you are starting up. How and if MATLAB migrates (reuses) preferences files from one version of MATLAB to the next also depends on the version.

Process for Creating and Migrating Preferences Folder and Files

When you start up, MATLAB looks for a preferences folder name that matches the release starting up, and then it does one of the following:

  • If MATLAB finds a preferences folder name matching the release starting up, then it uses that folder and the files within it. This is usually the case after the first time you start MATLAB for a given release.

    If a preference folder exists but is empty, then MATLAB recreates the default preference files for the release starting up.

  • If MATLAB does not find a preferences folder name matching the release starting up, then it creates one. Next, MATLAB checks to see if a preference folder exists for any of the three releases of MATLAB that immediately precede the one you are starting.

    • If none of the preference folders from the previous three releases exist, then MATLAB creates the default preference files for the release starting up.

      For example, if you start up R2016a and neither R2015b, R2015a, or R2014b are installed, then MATLAB creates the default files for the R2016a release. This is true even if a preference folder exists for the R2014a release or earlier.

    • If one or more of the preference folders for the previous three releases exist, then MATLAB migrates the files from the preferences folder corresponding to the latest previous release to the preferences folder for the release starting up.

      For example, if you start up R2016a and a preference folder exists for both the R2015b and R2014b releases, then MATLAB migrates the files from the R2015b preferences folder to the R2016a preferences folder.

Control Preferences Files MATLAB Uses

This table describes how to control which versions of preferences files MATLAB uses.

To Use:Do This:

Default preference files for a given release of MATLAB

  • If a preference folder for the given release exists, make sure that the folder is empty before starting up.

  • If a preference folder for the given release does not exist and one or more of the preference folders for the previous three releases do exist, create an empty preferences folder for the given release.

All the preference files from a release of MATLAB up to three releases preceding the release you plan to start up or sign into.

Ensure that the preferences folder exists for that previous release. Delete the entire preferences folder for each release after the release you want to migrate from, including the folder for the release of MATLAB you plan to start up or sign into.

The release-specific default for just a particular file in the preferences folder

Delete just that file from the preferences folder for the release of MATLAB you plan to start up or sign into.

One file to consider keeping is history.m. For more information, see Set Command History Preferences.

General Preferences

You can set preferences for the initial working folder, deleting files, and toolbox path caching.

On the Home tab, in the Environment section, click Preferences. Select MATLAB > General. Then, adjust preference options as described in this table.

PreferenceUsage

Initial working folder

Select the last working folder from your previous MATLAB session, or specify the full path to a folder on your system. For more information, see MATLAB Startup Folder.

If you create a startup.m file, cd commands in that file override the preference option.

Deleting files

Select an option to specify what MATLAB does with files you delete using the delete function.

Selecting Delete permanently makes the delete function run faster.

On Linux® systems, if you select Move to a temporary folder, MATLAB moves files to a subfolder with the prefix MATLAB_Files_ in the system temporary folder, as returned by the tempdir function.

Toolbox path caching

Select Enable toolbox path caching to have MATLAB cache matlabroot folder information across sessions for quicker startup performance.

Click Update Toolbox Path Cache to add files to the matlabroot folder. (Use after you use tools not provided with MATLAB to create MATLAB files.)

For details, see Toolbox Path Caching in MATLAB.

Desktop language (selected non-English systems only)

Select the language in which the MATLAB desktop appears. Supported languages include Japanese, Korean, and Chinese. This option affects the text in dialog boxes, button names, menu items, and error and warning messages. For more information, see MATLAB Desktop Language Preference.

This option is only available for selected non-English systems.

Confirmation Dialog Boxes Preferences

You can specify whether MATLAB displays specific confirmation dialog boxes.

On the Home tab, in the Environment section, click Preferences. Select MATLAB > General > Confirmation Dialogs. Then, adjust preference options as described in the table below.

This table summarizes the core MATLAB confirmation dialog boxes. There might be additional confirmation dialog boxes for other products you install, and some options are not available in MATLAB Online.

Option

Confirmation Dialog Box Appears

Warn before deleting Command History items

When you delete entries from the Command History window.

For details, see Command History Window.

Warn before clearing the Command Window

When, on the Home tab, in the Code section, you click Clear Commands. Does not appear when you use the clc function.

Confirm when overwriting variables in MAT-files

When you save variables by dragging them from the Workspace browser onto a MAT-file in the Current Folder browser.

Confirm when overwriting workspace variables via drag-and-drop

When you load variables by dragging them from the Details Panel of the Current Folder browser to the Workspace browser or Command Window.

Prompt when editing files that do not exist

When you type edit filename and filename does not exist in the current folder or on the search path.

Prompt to exit debug mode when saving file

When you try to save a modified file while in debug mode.

For details, see End Debugging Session.

Prompt to save on activate

When you have unsaved changes to a figure and program file and you activate the UI by clicking the Run button, for example.

For details, see GUIDE Preferences.

Prompt to save on export

When you have unsaved changes to a figure and program file and you select File > Export.

For details, see GUIDE Preferences.

Confirm changing default callback implementation

When you have modified a callback signature in GUIDE.

For details, see GUIDE Preferences.

Confirm before exiting MATLAB

When you quit MATLAB.

Confirm when deleting variables

When you delete variables from the workspace using menu items. Does not appear with the clear function.

For details, see Save and Load Workspace Variables.

Source Control Preferences

You can select which previously installed and configured source control system to use with MATLAB.

On the Home tab, in the Environment section, click Preferences. Select MATLAB > General > Source Control. Then, select an option from the list.

For more information, see Select or Disable Source Control System.

Keyboard Shortcuts Preferences

You can set keyboard shortcuts for actions you perform using MathWorks software. You can specify or import sets of predefined keyboard shortcuts, set individual shortcuts on an action-by-action basis, or use a combination of both approaches.

On the Home tab, in the Environment section, click Preferences. Select MATLAB > Keyboard > Shortcuts. Then, adjust preference options as described in this table.

For more information on customizing keyboard shortcuts, see Customize Keyboard Shortcuts for Individual Actions.

If you use source control integration through the MATLAB Current Folder Browser, MATLAB might crash when you view or commit changes.

PreferenceUsage
Active settings

Select or import a set of predefined keyboard shortcuts.

Select any one of these options:

  • Save As — Save current set of keyboard shortcuts to a file.

  • Copy to clipboard — Copy current set of keyboard shortcuts to clipboard, so you can import into Microsoft® Excel®, for example.

  • Compare — Compare the current set of keyboard shortcuts to another set.

  • Undo Modifications — Undo changes to a default keyboard shortcut set.

  • Delete — Delete a set of keyboard shortcuts you previously saved or added.

Search by action name or shortcut

Search the list of displayed actions.

Shortcuts for <action-name>

View the keyboard shortcut assigned to a selected action.

Add or delete a keyboard shortcut to a selected action.

All possible conflicts

Display conflicts when two or more different actions have the same shortcut.

Remove the keyboard shortcut from the selection in the All possible conflicts list.

Colors Preferences

You can specify the text and background color for desktop tools, as well as colors for highlighting syntax elements of MATLAB code.

On the Home tab, in the Environment section, click Preferences. Select MATLAB > Colors. Then, set options as described in the table below.

PreferenceUsage
Desktop tool colors

Specify that desktop tools use the same text and background colors that your platform uses for other applications by selecting Use system colors.

Customize colors by clearing Use system colors, and then choose Text and Background colors from the drop-down menus.

The colors that you specify also apply to the Import Wizard, but do not apply to the Live Editor, the Help display pane or the web browser.

For details, see Change Text and Background Colors in Desktop Tools.

MATLAB syntax highlighting colors

Set colors to help you quickly identify elements of MATLAB syntax in the Editor, Live Editor, Command Window, Command History window, and the MATLAB shortcuts callback area.

For details, see Change Syntax Highlighting Colors.

MATLAB Command Window colors

Set colors to help you quickly identify errors, warnings, and hyperlinks in the Command Window.

Colors Programming Tools Preferences

You can specify options used for editing and debugging code, including code analysis colors, variable and function colors, and cell display options.

On the Home tab, in the Environment section, click Preferences. Select MATLAB > Colors > Programming Tools. Then, set options as described in the table below.

PreferenceUsage
Code analyzer colors
  • Warnings—Specifies the color Code Analyzer uses to identify code in the Editor and Live Editor for which there are warning messages.

  • Autofix highlight— Specifies the color Code Analyzer uses to identify code in the Editor and Live Editor for which there is an automatic fix.

For details, see Automatically Check Code in the Editor and Live Editor — Code Analyzer.

Variable and function colors
Section display options

Highlight sections— Specifies the color the Editor uses to shade code sections.

Show lines between sections— Specifies that code section divisions appear with a gray line between each section in the Editor. These lines do not appear in the published or printed file.

See also Code Sections.

Comparison Preferences

Colors

You can change and save your diff color preferences for the Comparison Tool. You can apply your color preferences to all comparison types.

On the Home tab, in the Environment section, click Preferences. Select MATLAB > Comparison. Then, set options as described in the table below.

PreferenceUsage
Colors

Set colors to help you quickly identify differences, modifications, and merges in comparison reports. Choose colors from the drop-down menus. View the colors in the Sample pane. To use your modified settings in comparisons, click Apply. Refresh any open comparison reports to use the new colors.

Active Settings

To save your modified color preferences for use in future MATLAB sessions, click Save As. Enter a name for your color settings profile and click OK.

After saving settings, you can select them in the Active Settings list.

For details, see Comparison Report Tools and Options.

External Source Control Integration

Use the check box to control external source control interactions: Allow external source control tools to use open MATLAB sessions for diffs and merges. After you configure your source control tool to use MATLAB Comparison Tool, the Comparison Tool prompts you to set this preference. For details, see Customize External Source Control to Use MATLAB for Diff and Merge (Simulink).

Toolbars Preferences

You can customize some toolbars in the MATLAB application.

On the Home tab, in the Environment section, click Preferences. Select MATLAB > Toolbars. Then, set options as described in the table below.

For step-by-step instructions on setting these preferences, see Access Frequently Used Features.

PreferenceUsage
Toolbar

Select the toolbar you want to customize.

Layout

Rearrange controls in the toolbar by dragging and dropping them to a new location in the Layout.

Controls

Select which buttons appear on the selected toolbar.

See Also

Related Topics