MATLAB Desktop Tools and Development Environment
MATLAB Desktop Tools and Development Environment
R2023a
How to Contact MathWorks
Phone: 508-647-7000
v
Passing Perl Variables on Startup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-19
Startup and Calling Java Software from MATLAB . . . . . . . . . . . . . . . . . . 1-19
Desktop
2
Zoom and Change Desktop Fonts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-2
Zoom . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-2
Change Font Size . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-2
Change Font Name and Style . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-3
Advanced Customization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-4
Add New Font . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-5
vi Contents
MATLAB Online . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-29
Navigate Figures in MATLAB Online . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-30
Additional Keyboard Shortcuts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-31
vii
Entering Commands
3
Enter Statements in Command Window . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-2
viii Contents
Filter Results . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-6
Where the Search Engine Searches . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-6
ix
Managing Files in MATLAB
6
Find Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-2
Simple Search for File Names . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-2
Advanced Search for Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-2
Advanced Search in MATLAB Online . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-4
x Contents
Case Sensitivity of File Names . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-43
Editor Preferences
7
Editor/Debugger Preferences . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-2
General Preferences for the Editor/Debugger . . . . . . . . . . . . . . . . . . . . . . 7-2
Editor/Debugger Display Preferences . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-3
Editor/Debugger Tab Preferences . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-4
Editor/Debugger Language Preferences . . . . . . . . . . . . . . . . . . . . . . . . . . 7-5
Editor/Debugger Code Folding Preferences . . . . . . . . . . . . . . . . . . . . . . . 7-7
Editor/Debugger Backup Files Preferences . . . . . . . . . . . . . . . . . . . . . . . . 7-8
Editor/Debugger Autoformatting Preferences . . . . . . . . . . . . . . . . . . . . . . 7-9
Editor/Debugger Automatic Completions Preferences . . . . . . . . . . . . . . . 7-10
Editor/Debugger Saving Preferences . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-13
xi
Code Analyzer Preferences . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-14
Code Analyzer Preferences . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-14
Search for Messages in the Code Analyzer Preferences . . . . . . . . . . . . . 7-15
Add-Ons
8
Get and Manage Add-Ons . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-2
Get Add-Ons . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-2
Install Add-Ons from File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-3
Default Add-On Installation Folder . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-3
Manage Add-Ons . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-4
Update Add-Ons . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-4
Run Apps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-4
xii Contents
Internationalization
9
Locale Setting Concepts for Internationalization . . . . . . . . . . . . . . . . . . . . 9-2
Default Locale Setting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-2
Supported Character Sets and Encodings . . . . . . . . . . . . . . . . . . . . . . . . . 9-2
Platform-Specific Localized Formats for Current Folder Browser . . . . . . . . 9-3
MATLAB Online
10
Access Files in MATLAB Online . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-2
Upload and Download Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-2
Preview Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-2
Restore Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-2
Cloud Storage
11
Open in MATLAB Online from GitHub . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-2
Create Links . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-2
Share Links . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-2
xiii
MATLAB Drive
12
Install MATLAB Drive Connector . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-2
Install Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-2
Uninstall Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-2
Post-Installation Tasks
13
Configure the MATLAB Startup Accelerator . . . . . . . . . . . . . . . . . . . . . . . 13-2
Change When the MATLAB Startup Accelerator Runs . . . . . . . . . . . . . . . 13-2
xiv Contents
1
When you start MATLAB, it automatically adds the userpath folder to the search path. MATLAB also
reopens any desktop components that were open when you last shut down.
The MATLAB startup folder is the folder you are in when you get the MATLAB prompt. To change the
default startup folder, see “MATLAB Startup Folder” on page 1-14.
If you have trouble starting MATLAB, then see “Installation and Licensing”.
You also can specify a custom startup folder in the MATLAB shortcut icon using the Start in field.
However, this technique is the same as setting a custom path in the Initial working folder
preference. If you enter an invalid path in the Start in field, then the startup folder is unpredictable.
To set a custom path in the Start in field:
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 Start in field, type the full path to a folder on your system, and then click OK.
The startup folder is the folder in which you run the matlab command. To use the folder specified by
the Initial working folder preference, type:
matlab -useStartupFolderPref
!matlab
1-2
Start MATLAB on Windows Platforms
For example, using the Windows Explorer tool, double-click a file with a .m extension. MATLAB starts
and opens the file in the MATLAB Editor.
See Also
matlab (Windows) | userpath | Preferences
More About
• “Specify Startup Options” on page 1-18
• “MATLAB Startup Folder” on page 1-14
• “Installation and Licensing”
1-3
1 Startup and Shutdown
By default, MATLAB associates the latest installed version to MATLAB file types. However, once you
use the Windows Control Panel or the file manager to associate a MATLAB version to a file type, you
must manually re-associate the type with each new installation of MATLAB. If you want to return to
the default behavior, then uninstall every MATLAB that is manually associated to any MATLAB file
type. Then reinstall the latest MATLAB release.
1-4
Start MATLAB on Linux Platforms
To start MATLAB on Linux platforms, type matlab at the operating system prompt. If you did not set
up symbolic links in the installation procedure, then type matlabroot/bin/matlab. matlabroot is
the name of the folder in which you installed MATLAB. To see the folder, type matlabroot.
After starting MATLAB, the desktop opens. Desktop components that were open when you last shut
down MATLAB reopen. If the DISPLAY environment variable is not set or is invalid, then the desktop
does not display.
The MATLAB startup folder is the folder you are in when you get the MATLAB prompt. To change the
default startup folder, see “MATLAB Startup Folder” on page 1-14.
If you have trouble starting MATLAB, then see “Installation and Licensing”.
Startup Folder
On Linux platforms, the default startup folder is the folder from which you started MATLAB.
To specify the userpath as the startup folder, set the value of the environment variable
MATLAB_USE_USERWORK to 1 before startup. By default, userpath is userhome/Documents/
MATLAB. To specify a different folder for userpath, and for other options, call the MATLAB
userpath function.
The ssh command pipes hello.m to MATLAB running on the remote host local.foo.com. The -
nodisplay option starts MATLAB without the desktop.
See Also
matlab (Linux) | userpath | matlabroot | Preferences
More About
• “Specify Startup Options” on page 1-18
• “MATLAB Startup Folder” on page 1-14
• “Installation and Licensing”
1-5
1 Startup and Shutdown
When you start MATLAB, it automatically adds the userpath folder to the search path. MATLAB also
reopens any desktop components that were open when you last shut down.
The MATLAB startup folder is the folder you are in when you get the MATLAB prompt. To change the
default startup folder, see “MATLAB Startup Folder” on page 1-14.
If MATLAB fails to start due to a problem with required system components such as Java® software,
then diagnostics run automatically. The software advises you of the problem and offers suggestions to
correct it. For information about other startup problems, see “Installation and Licensing”.
The startup folder is the last working folder from the previous MATLAB session or the custom path
specified in the Initial working folder preference. The Initial working folder preference is located
in the General Preferences page of the Preferences window.
matlabroot/bin
• Start MATLAB.
./matlab
See Also
matlab (macOS) | userpath | matlabroot | Preferences
More About
• “Specify Startup Options” on page 1-18
1-6
Start MATLAB on macOS Platforms
1-7
1 Startup and Shutdown
Exit MATLAB
In this section...
“Ways to Quit or Exit” on page 1-8
“Confirm Exiting” on page 1-8
“Run Script When Exiting” on page 1-9
Confirm Exiting
To set a preference that displays a confirmation dialog box when you exit:
MATLAB then displays the following dialog box when you exit.
You can also display your own exit confirmation dialog box using a finish.m script, as described in
the following section.
1-8
Exit MATLAB
There are two sample files in matlabroot/toolbox/local that you can use as the basis for your
own finish.m file:
See Also
exit | quit | finish | Preferences
More About
• “Recovering Data After Abnormal Termination” on page 1-10
• “Crash Reporting” on page 1-11
• “Installation and Licensing”
1-9
1 Startup and Shutdown
• Use the Command History or the file on which it is based, history.m, to run statements from the
previous session. You might be able to recreate data as it was before the termination.
• If you used the diary function or -logfile startup option for the session in which MATLAB
terminated unexpectedly, then you might be able to recover output.
• If you saved the workspace to a MAT-file during the session, then you can recover it by loading the
MAT-file.
• If you were editing a file in the Editor when MATLAB terminated unexpectedly, and you had the
backup feature enabled, then you should be able to recover changes you made to files you had not
saved. To recover, open the backup version filename.asv in the Editor. Then save it as
filename.m to use the last good version of filename.
• If you were in a Simulink® session when a segmentation violation occurred, and you have the
Simulink Autosave Options preference selected, then the last autosave file for the model reflects
the state of the autosave data before the segmentation violation. Because Simulink models might
be corrupted by a segmentation violation, a model is not autosaved after a segmentation violation
occurs. To recover the file, open the model.
See Also
diary | save | load
Related Examples
• “Save and Load Workspace Variables” on page 5-12
• “Save and Back Up Code”
More About
• “Commonly Used Startup Options” on page 1-17
1-10
Crash Reporting
Crash Reporting
If MATLAB crashes, then the MathWorks Crash Reporter dialog box prompts you to send the crash
report to MathWorks. Doing so helps us improve our products. The crash report contains one or more
crash logs containing information on the stack trace and the MATLAB configuration. You can see the
entire contents of the crash report by clicking the Show Report button in the dialog box. This data,
along with information that you provide as reproduction steps, is the only information sent to
MathWorks.
Reproduction steps are most helpful if you know what appears to cause the crash, but any
information on what you were doing at the time helps our developers better understand the cause.
• If you do know the cause of the crash, then look for information about it in the MathWorks Bug
Reports database.
• If the problem is reproducible, then submit a Service Request at https://www.mathworks.com/
support/contact_us.html.
• On Windows platforms
dir(fullfile(tempdir,'prefix.*.*'))
dir(fullfile('~','prefix.*'))
See Also
tempdir
More About
• “When MATLAB Terminates Unexpectedly” on page 1-12
1-11
1 Startup and Shutdown
If you do not receive an email, then you can directly contact Technical Support at https://
www.mathworks.com/support/contact_us.html.
After viewing the solution, if you feel that it is not relevant, then click Send Report and enter
reproduction steps in the window.
If you apply the fix and still experience a crash, then click Send Report or create a Service Request
directly at https://www.mathworks.com/support/contact_us.html.
See Also
More About
• “Crash Reporting” on page 1-11
1-12
Specifying Java Startup Options
• MATLAB startup folder, if starting MATLAB from an operating system prompt. For more
information, see “MATLAB Startup Folder” on page 1-14.
• If there is no java.opts file in the startup folder, then MATLAB checks the matlabroot/bin/
arch folder. matlabroot is the output of the matlabroot function. arch is the output of the
MATLAB computer('arch') function, for example glnxa64.
A java.opts file in this location applies to all users, but individual users might not have
permissions to modify files there.
• To enable the use of the Java debugger, use the matlab -jdb command. For information, see
matlab (Linux) or matlab (macOS).
• To adjust the Java heap size on desktop versions of MATLAB, use “Java Heap Memory
Preferences”.
• To modify the static Java class path, create a javaclasspath.txt file. For information, see
“Static Path of Java Class Path”.
To modify the library path, create a javalibrarypath.txt file. For information, see “Locate
Native Method Libraries”.
• To override built-in options that MATLAB specifies to Java at startup. Options in java.opts are
appended to the end of the built-in list. Whether these additional options override built-in options
is JVM-dependent and can change between Java versions. To see what options MATLAB provides
to Java, run this command:
java.lang.management.ManagementFactory.getRuntimeMXBean.getInputArguments
See Also
matlab (Linux) | matlab (macOS)
Related Examples
• “Java Heap Memory Preferences”
• “Static Path of Java Class Path”
• “Locate Native Method Libraries”
More About
• “MATLAB Startup Folder” on page 1-14
1-13
1 Startup and Shutdown
Note If a startup.m file changes the current folder, then this value overrides the initial working
folder value. Do not add cd statements to startup.m. For more information about user-defined
options, see startup.
For more information, see “Start MATLAB on Windows Platforms” on page 1-2.
If you start MATLAB by double-clicking the MATLAB shortcut icon and the startup folder is set to an
unexpected location, follow these steps to ensure that the Start in field in the MATLAB shortcut icon
is empty:
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 If the Start in field contains text, clear the text.
3 Click OK and try starting MATLAB again.
1-14
MATLAB Startup Folder
For more information, see “Start MATLAB on macOS Platforms” on page 1-6.
On Linux platforms, the default startup folder is the folder from which you started MATLAB.
For more information, see “Start MATLAB on Linux Platforms” on page 1-5.
Alternatively on Windows platforms, specify the initial working folder in the MATLAB shortcut icon.
For more information, see “Select MATLAB Icon” on page 1-2.
• You can store the MATLAB files you work with in one folder, such as Documents/MATLAB.
• You can always run your files because MATLAB automatically adds the userpath folder to the top
of the search path.
• The first time you run a new version of MATLAB, the software automatically creates the
userpath folder if it does not exist.
• When you upgrade to a newer version of MATLAB, the software automatically continues to use the
same startup folder and your existing files.
• The default userpath uses the benefits provided by the standard location in the Windows and
macOS environments for storing personal files. Files in the Documents/MATLAB folder are
available to you when you use other machines. Each user has an individual Documents/MATLAB
folder. Other users, even those using your machine, cannot access files in your Documents/
MATLAB folder.
See Also
startup | Preferences
1-15
1 Startup and Shutdown
Related Examples
• “Start MATLAB on Windows Platforms” on page 1-2
• “Start MATLAB on macOS Platforms” on page 1-6
• “Start MATLAB on Linux Platforms” on page 1-5
1-16
Commonly Used Startup Options
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 -batch "statement" Run the specified statement non-interactively.
All -r "statement" Run the specified statement interactively.
All -singleCompThread Limit MATLAB to a single computational thread. This option is for
numerical computations only.
For a complete list of options, refer to the input arguments for matlab (Windows), matlab
(macOS), or matlab (Linux).
See Also
matlab (Windows) | matlab (macOS) | matlab (Linux)
1-17
1 Startup and Shutdown
In this section...
“Startup Options from Operating System Prompt” on page 1-18
“Startup Options in Shortcut on Windows Systems” on page 1-18
“Startup Options in MATLAB Startup File” on page 1-19
“Passing Perl Variables on Startup” on page 1-19
“Startup and Calling Java Software from MATLAB” on page 1-19
matlab -nosplash
On Windows platforms, you can precede a startup option with either a hyphen (-) or a slash (/). For
example, -nosplash and /nosplash are equivalent.
To use startup options for the MATLAB shortcut icon, 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.
This example runs the MATLAB results script or function after startup, where results.m is in the
startup folder or on the MATLAB search path. The text in the Target field is similar to the following:
Include the statement, but not the option (-r) in double quotation marks.
Use semicolons or commas to separate multiple statements. This example changes the format to
short, and then runs the MATLAB code file results:
Separate multiple options with spaces. This example starts MATLAB without displaying the splash
screen, and then runs the MATLAB code file results:
1-18
Specify Startup Options
The startup.m file is a file you create to specify startup options. Create the startup.m file in a
folder on the MATLAB search path. Use startup.m to modify the default search path, predefine
variables in your workspace, or define defaults for graphics objects. For example, the following
statement adds the user-defined folder /home/myname/mytools to the search path.
addpath /home/myname/mytools
To change the current folder on startup to mytools, set the Initial working folder value, located in
the General Preferences options in the Preferences window:
/home/myname/mytools
At startup, MATLAB automatically executes the matlabrc.m file and startup.m, if it exists on the
MATLAB search path. The file matlabrc.m, which is in the matlabroot/toolbox/local folder, is
reserved for use by MathWorks and by system administrators on multiuser systems. To locate the
startup.m file, type:
which startup
If MATLAB finds a startup.m file, then it displays the path to the file.
Note
MATLAB executes any file on the search path named startup that has an executable file extension.
Examples of an executable file extension are .m, .mlx, and .mlapp.
To pass a Perl variable instead of a constant as the input parameter, follow these steps. This command
starts MATLAB and runs test with the input argument 10.
1 Create a Perl script such as
#!/usr/local/bin/perl
$val = 10;
system('matlab -r "test(' . ${val} . ')"');
2 Invoke the Perl script at the prompt using a Perl interpreter.
For more information, see the -r option in matlab (Windows), matlab (macOS), or matlab
(Linux).
1-19
1 Startup and Shutdown
For information about memory allocation for Java objects, see “Java Heap Memory Preferences”.
See Also
matlab (Windows) | matlab (macOS) | matlab (Linux) | Preferences
More About
• “Commonly Used Startup Options” on page 1-17
• “What Is the MATLAB Search Path?” on page 6-46
1-20
Toolbox Path Caching in MATLAB
In this section...
“About Toolbox Path Caching in MATLAB” on page 1-21
“Using the Cache File Upon Startup” on page 1-21
“Updating the Cache and Cache File” on page 1-21
MATLAB does not use the cache file at startup if you clear the Enable toolbox path cache check
box in General Preferences page of the Preferences Window. Instead, it creates the cache by
reading from the operating system folders, which is slower than using the cache file.
MATLAB caches (essentially, stores in a known files list) the names and locations of files in the
matlabroot folder. This folder is for files provided with MathWorks products that should not change
except for product installations and updates. Caching those folders provides better performance
during a session because MATLAB does not actively monitor those folders.
We strongly recommend that you save any MATLAB code files you create and any files provided by
MathWorks that you edit in a folder that is not in the matlabroot folder tree. If you keep your files
in the matlabroot folder, then they might be overwritten when you install a new version of MATLAB.
When you add files to the matlabroot folder, the cache and the cache file need to be updated.
MATLAB updates the cache and cache file automatically when you install toolboxes or toolbox
updates using the installer for MATLAB. MATLAB also updates the cache and cache file automatically
when you use MATLAB tools, such as when you save files from the MATLAB Editor to the
matlabroot folder.
When you add or remove files in the matlabroot folder by some other means, MATLAB might not
recognize those changes. For example, when you:
1-21
1 Startup and Shutdown
and then attempt to use one of the new files, MATLAB displays this message:
Update the cache so MATLAB recognizes the changes you made in the matlabroot folder.
1 On the Home tab, in the Environment section, click Preferences. Select MATLAB >
General.
2 Click Update Toolbox Path Cache and click OK.
Function Alternative
To update the cache, use rehash toolbox. To update both the cache and the cache file, use rehash
toolboxcache. For more information, see rehash.
1-22
Remove canberra-gtk-module and pk-gtk-module Messages
To suppress these messages, open a terminal with root privileges and execute the relevant commands
to install the libcanberra Linux package.
• sh or bash commands:
$ export GTK_PATH=/usr/lib64/gtk-2.0
• csh/tcsh commands:
Debian-Based Distributions
On Debian®-based distributions (including Ubuntu®):
• sh or bash commands:
$ export GTK_PATH=/usr/lib/x86_64-linux-gnu/gtk-2.0
• csh/tcsh commands:
1-23
2
Desktop
You can change the zoom level, font size, name, and style used by tools in MATLAB. You also can
install new fonts to use with MATLAB.
Zoom
You can change the zoom level in the Editor, Live Editor, and Help browser. To zoom in and out, hold
the Ctrl key and move the scroll wheel. On macOS systems, use the Command key instead.
Alternatively, you can zoom in and out using the available keyboard shortcuts.
Alternatively, you can change the zoom level in the Editor and Live Editor by going to the View tab
In MATLAB Online™, to change the zoom level, adjust the zoom settings for your web browser.
Tool Procedure
Live Editor Specify the font size for code and text
programmatically using settings. For example,
this code changes the code font size in the Live
Editor.
s = settings;
s.matlab.fonts.editor.code.Size.TemporaryValue = '26p
2-2
Zoom and Change Desktop Fonts
Tool Procedure
Code tools Specify the font size using font preferences.
In MATLAB Online, to change the font size, in the Preferences window, go to MATLAB >
Appearance > Fonts. Changing the font size is only supported for the Editor, Live Editor, Command
Window, and Command History.
Tool Procedure
Live Editor Specify the font name and style for code and text
programmatically using settings. For example,
this code changes the font name and style of
normal text in the Live Editor.
s = settings;
s.matlab.fonts.editor.normal.Name.PersonalValue = 'Ca
s.matlab.fonts.editor.normal.Style.PersonalValue = {'
2-3
2 Desktop
Tool Procedure
Code tools Specify the font name and style using font
preferences.
• Editor
• Command Window On the Home tab, in the Environment section,
• Command History click Preferences. Select MATLAB > Fonts
and, in the Desktop code font section, select a
font name and style.
In MATLAB Online, to change the font name and font style, in the Preferences window, go to
MATLAB > Appearance > Fonts. Changing the font size is only supported for the Editor, Live
Editor, Command Window, and Command History.
To apply antialiasing and create a smoother desktop appearance on Linux systems, select Use
antialiasing to smooth desktop fonts. You must restart MATLAB for the preference to take effect.
On Microsoft Windows and macOS platforms, MATLAB uses system setting for antialiasing.
Advanced Customization
You can further customize fonts in MATLAB by changing the font preferences for an individual tool.
To change the font preferences, on the Home tab, in the Environment section, click
Preferences. Select MATLAB > Fonts > Custom and choose a tool from the list of Desktop tools.
Then, select the font to use:
• Desktop code — Select this option to use the desktop code font for this tool.
• Desktop text — Select this option to use the desktop text font for this tool.
• Custom — Select this option to specify a custom font for this tool. Then, specify a font name,
style, and size. Some options are not supported for all tools.
2-4
Zoom and Change Desktop Fonts
For example, to change the Editor font to a custom font, in the list of Desktop tools, select Editor.
Then, in the Font to use section, select Custom and specify the desired font name, style, and size.
In MATLAB Online, setting custom font preferences is only supported for the Editor, Command
Window, and Command History.
To change the font name and style of code and text for the Live Editor, use settings. For more
information, see matlab.fonts Settings.
This table shows the default font preferences for the tools in MATLAB. You can use this table to
restore fonts to their original state.
Choose a new font that is compatible with MATLAB. MATLAB only includes compatible fonts in the
font preferences.
• For desktop components (such as the Command Window), figure windows, and uicontrols, fonts
must be compatible with TrueType and Microsoft OpenType® fonts
• For graphics objects, such as xlabel, ylabel, title, and text, fonts must be TrueType and
Microsoft OpenType fonts
Install your new font in a location where MATLAB looks for fonts. MATLAB looks for fonts in these
locations:
2-5
2 Desktop
• The operating system's standard location (see your system administrator for details)
• The /jre/lib/fonts folder where Java software is installed on your system
If you install a font with MATLAB running, restart MATLAB to include the font in the font
preferences.
Then, to use the new font, follow the instructions in “Change Font Name and Style” on page 2-3.
See Also
Preferences
Related Examples
• “Add Title and Axis Labels to Chart”
• “Change Desktop Colors” on page 2-7
• “Set Print Options for Command Window and Editor” on page 2-47
2-6
Change Desktop Colors
You can change the colors used by tools in MATLAB, including the text and background colors, syntax
highlighting colors, and output colors. In MATLAB Online, you also can use themes to change the
colors of the MATLAB desktop, for example, by selecting a dark theme. For more information, see
“Select Theme in MATLAB Online” on page 2-10.
In MATLAB Online, the Use system colors check box is not available and this step can be
skipped.
4 Use the Text and Background fields to change the colors. For example, select white for the text
color and black for the background color.
The Syntax Highlighting sample and Command Window sample areas show a preview of the
selected colors.
To restore the default text and background colors, click the Restore Default Colors button at
the bottom of the Preferences window.
The Live Editor automatically selects colors for titles and headings based on the selected background
color. To further customize the colors of titles and headings, use settings. For more information, see
matlab.fonts Settings.
Changing the text and background colors does not change the colors of the toolstrip or Help browser.
In MATLAB Online, changing the text and background colors also does not change the colors of the
Workspace panel.
2-7
2 Desktop
MATLAB conveys syntax information in code using different colors. This feature, known as syntax
highlighting, helps you to identify syntax elements, such as if/then/else statements, at a glance.
Syntax highlighting appears in code files, in code you enter in the Command Window, and in error
and warning messages. It does not appear in other kinds of output.
The Syntax highlighting sample area shows a preview of the selected colors.
To restore the default syntax highlighting colors, click the Restore Default Colors button at the
bottom of the Preferences window.
To disable syntax highlighting, in the Preferences window, select MATLAB > Editor/Debugger >
Language. Then, in the Syntax highlighting section, clear the Enable syntax highlighting check
box. In MATLAB Online, this option is located under MATLAB > Editor/Debugger > MATLAB
Language.
The Editor also provides syntax highlighting for other languages. To change the syntax highlighting
colors for other languages, in the MATLAB > Editor/Debugger > Language Preferences window,
select a language in the Language field. Then, change the colors for that language. To disable syntax
highlighting for the language, clear the Enable syntax highlighting check box. In MATLAB Online,
these options are located under MATLAB > Editor/Debugger > Other Languages.
For more information about syntax highlighting, see “Check Syntax as You Type” on page 3-20.
2-8
Change Desktop Colors
To change the colors used for errors, warnings, and links in output:
1 On the Home tab, in the Environment section, click Preferences.
2 Select MATLAB > Colors.
The Command Window sample area shows a preview of the selected colors.
To restore the default output colors, click the Restore Default Colors button at the bottom of
the Preferences window.
In the Editor and Live Editor, MATLAB uses additional colors to identify Code Analyzer messages,
variables, and functions. To change these colors, go to the Home tab, and in the Environment
section, click Preferences. Then, select MATLAB > Colors > Programming Tools. In MATLAB
Online, select MATLAB > Appearance > Colors > Programming Tools.
To change the colors used to identify Code Analyzer messages in the Editor and Live Editor, in the
Code analyzer colors section, select colors from the Warnings and Autofix highlight fields. To
disable highlighting autofixes in the Editor and Live Editor, clear the Autofix highlight check box.
For more information about using the Code Analyzer, see “Check Code for Errors and Warnings Using
the Code Analyzer”.
When you select a variable or function in the Editor or Live Editor, MATLAB highlights all
occurrences of that specific variable or function. To change the color of this highlight, in the Variable
and function colors section, select a color from the Automatically highlight field. To disable
automatic highlighting in the Editor and Live Editor, clear the Automatically highlight check box.
For more information about automatic highlighting, see “Find and Replace Functions or Variables in
Current File”.
MATLAB also uses text of a different color to call out variables with shared scope in the Editor and
Live Editor. To change the color of variables with shared scope, in the Variable and function colors
2-9
2 Desktop
section, select a color from the Variables with shared scope field. To disable calling out variables
with shared scope in the Editor and Live Editor, clear the Variables with shared scope check box.
For more information about variables with shared scope, see “Check Variable Scope in Editor”.
Windows and macOS systems support light and dark color schemes. By default, MATLAB Online is
configured to match the current operating system color scheme using the system theme. If the
selected color scheme for the operating system changes, the colors of the MATLAB desktop change to
match the new scheme.
To change the selected theme, on the Home tab, in the Environment section, click Preferences.
Select MATLAB > Appearance and select a theme from the Theme field. For example, select Dark
to select a dark theme or System to select a theme that matches the current operating system
scheme.
The MATLAB Appearance Preferences page shows a preview of the selected theme.
After selecting a theme, you can further customize the colors of the MATLAB desktop by selecting
MATLAB > Appearance > Colors and changing the colors in the Desktop tool colors, MATLAB
syntax highlighting colors, and MATLAB output colors sections.
Note MATLAB does not save color customizations when the theme changes. If you select a new
theme or the theme changes to match a modification to the operating system color scheme, MATLAB
reverts to using the default colors for that theme and your customizations are lost. To avoid
unexpectedly losing color customizations when the operating system color scheme changes, select
the Light or Dark option from the Theme field before making any color customizations.
2-10
Change Desktop Colors
See Also
matlab.fonts | Preferences
Related Examples
• “Zoom and Change Desktop Fonts” on page 2-2
• “Set Print Options for Command Window and Editor” on page 2-47
2-11
2 Desktop
By default, the quick access toolbar is located at the upper-right corner of the MATLAB desktop. To
change the location of the quick access toolbar, on the Home tab, in the Environment section, click
Layout, and then select an option for the Quick Access Toolbar. Moving the quick access toolbar is
not supported in MATLAB Online.
To add a toolstrip control to the quick access toolbar, right-click the control and then select Add to
Quick Access Toolbar. You also can select from a list of common controls by going to the quick
access toolbar and clicking the button. To remove a control from the quick access toolbar, right-
click the control and select Remove from Quick Access Toolbar. To arrange controls in the quick
access toolbar, drag them to the desired locations.
To further customize the quick access toolbar, click the button on the toolbar and select
Customize Toolbar. Then, select from the options described in “Toolbar Preferences” on page 2-12.
By default, the Current Folder toolbar is located under the toolstrip. To change the location of the
Current Folder toolbar, on the Home tab, in the Environment section, click Layout, and then select
an option for the Current Folder Toolbar. Moving the Current Folder toolbar is not supported in
MATLAB Online.
To add, remove, or rearrange the controls that appear in the Current Folder toolbar, right-click the
toolbar and select Customize. Then, select from the options described in “Toolbar Preferences” on
page 2-12.
Toolbar Preferences
You can customize the quick access and Current Folder toolbars using the Toolbar preferences. To
open the Toolbar preferences, go to the Home tab, and in the Environment section, click
Preferences. Select MATLAB > Toolbars and in the Toolbar section, select the toolbar that you
want to customize.
To rearrange controls in the selected toolbar, in the Layout section, drag the icon for a control or
separator bar to a new location. You also can select a control icon or separator bar and then use the
buttons below the control icons to move the selected control. For example, to move the MATLAB
2-12
Customize MATLAB Toolbars
desktop Cut button to the beginning of the quick access toolbar, select the Cut icon , and then click
the button.
To add or remove controls from the selected toolbar, select or clear the check box for those controls.
For example, to easily create new folders in the current folder, you can add a New Folder button to
the Current Folder toolbar. To do so, select the Folder button and click OK. MATLAB adds the
button to the toolbar.
See Also
Preferences
More About
• “Rerun Favorite Commands” on page 3-14
• “Use Keyboard Shortcuts to Navigate MATLAB” on page 2-28
• “Customize Keyboard Shortcuts” on page 2-42
2-13
2 Desktop
When you start MATLAB, the desktop appears in its default layout.
2-14
Change Desktop Layout
To change the desktop layout, you can choose from a set of preconfigured desktop layouts or you can
create your own layout by hiding, minimizing, and undocking individual tools. You also can change
the layout of documents within a tool by undocking, reordering, or tiling them. Then, you can save
your layouts and reuse them again at a later time.
In MATLAB Online, you also can use the sidebars on either side of the desktop to access desktop tools
and change the desktop layout. The sidebars show the tools, such as the Workspace panel and the
Files panel, that are docked on either side of the desktop. If there are no tools docked on one side,
the sidebar for that side is hidden. You can use the sidebars to show and hide tools, group them
together, and move them from one location to another.
For example, if you work mostly in the Command Window, select the All but Command Window
Minimized option (Command Window Only in MATLAB Online) to maximize the Command Window
and minimize all other tools in the desktop.
2-15
2 Desktop
Hide Tools
To hide a tool, click the button on the title bar of a tool and select Close. You also can close some
tools by going to the Home tab, and in the Environment section, clicking the Layout button. Then,
in the Show section, clear one or more of the options in the list. To hide just the title bar for all tools,
clear the Panel Titles option.
In MATLAB Online, to hide a tool, click its icon in the sidebar. You also can hide some tools by going
to the Home tab, and in the Environment section, clicking the Layout button. Then, in the Layout
Options section, clear one or more of the options in the list. You also can optimize your desktop
layout by minimizing tools.
Minimize Tools
Minimize tools in the desktop to optimize the layout while still maintaining quick access to tools that
you use periodically.
To minimize the toolstrip, at the lower right corner of the toolstrip, click the button. The toolstrip
minimizes but the tabs remain visible. To restore the toolstrip, select one of the tabs to display the
toolstrip, and then, in the lower right corner of the toolstrip, click the button.
2-16
Change Desktop Layout
To minimize other tools including the Current Folder browser, Command Window, Editor, and Live
Editor, on the title bar of the tool, click the button and select Minimize. The minimized tool
appears along the edge of the desktop indicated by the arrow in the Minimize icon. For example, the
minimize icon indicates that the tool minimizes to the right edge of the desktop by default. To
move a minimized tool to a different edge of the desktop, drag the tools to the desired location.
For example, to minimize the Current Folder browser, at top right of the Current Folder browser, click
the button and select Minimize. The Current Folder browser minimizes to the left side of the
screen.
To open a minimized tool temporarily on the desktop, click the tool. To restore the tool to its original
size, double click the tool. Alternatively, you can click the button and select Restore.
In MATLAB Online, to minimize a tool, click its icon in the sidebar. For example, if the MATLAB
Online desktop is in the default layout with the Files panel and Workspace panel open in the left
sidebar, you can hide both tools by clicking the icon group for the two tools. If the left or right sidebar
contains multiple tools, you can minimize an individual tool by clicking the Collapse button to the
left of its title bar.
2-17
2 Desktop
Open Tools
To open tools that you previously hid, on the Home tab, in the Environment section, click Layout.
Then, in the Show section, select the desktop tool that you want to show on the desktop.
You also can open some tools programmatically using a function. For example, to open the Editor, use
the edit function. To open the Workspace browser, use the workspace function.
Undock tools to open them in a separate window and move them outside the MATLAB desktop. To
undock a tool, on the title bar of the docked tool, click the button and select Undock. Alternatively,
drag the tool by its title bar to a new location outside of the MATLAB desktop. To move an undocked
tool back into the desktop, at the upper right of the undocked tool, click the button, and select
Dock.
You also can undock individual documents within a tool such as an individual script file open in the
Editor. To undock an individual document, right-click the document tab and select Undock.
Alternatively, you can click the button on the title bar of the tool and select Undock document.
For example, if you have the file fact.m open in the Editor, to undock just that file, on the title bar of
the Editor, click the button and select Undock fact.m. MATLAB opens fact.m in a separate
window and leaves the Editor docked in the desktop. To move the file back into the desktop, at the
top right of the undocked file, click the button and select Dock. If you have multiple undocked
documents and want to move them all back into the desktop, select Dock All in tool.
2-18
Change Desktop Layout
Undocked tools and documents appear on the Windows task bar, or the equivalent for your platform.
Click the task bar icon for a tool or document to make it active.
When you open MATLAB documents, they open in the associated tool, such as the Editor, Live Editor,
or Variables editor. Individual documents open as separate tabs within the tool. To optimize the layout
of multiple documents, you can reorder or tile them. You also can change where the tabs appear
within a tool.
By default, the tabs appear at the top of the document. To reorder individual document tabs within a
tool, drag the tabs to a different position. To reorder document tabs alphabetically, on the View tab,
in the Document Tabs section, select Alphabetize. In MATLAB Online, to alphabetize document
tabs, on the title bar of the tool, click the button and select Alphabetize.
To change the position of the tabs in a tool, on the View tab, click Tabs Position and select from the
available options. For example, to display tabs on the side of the Editor instead of at the top, with the
Editor open, go to the View tab, click Tabs Position, and select Left. MATLAB displays the Editor
tabs of the left side of the tool. In MATLAB Online, to change the position of the tabs in a tool, click
the button, select Tab Position, and select from the available options.
2-19
2 Desktop
To view multiple documents at once in a tool, you can tile the documents. To tile documents in the
Editor, Live Editor, and Variables editor, go to the View tab and in the Tiles section, select a tile
option. For example, to view two files side by side in the Editor, go to the View tab and select the
Left/Right button. In MATLAB Online, to tile documents, on the title bar of the tool, click the
button, select Tile All, and then select a tile option.
To move a tiled document, drag the document tab to another tile. If you drag it to a tile that already
contains a document, the document you are dragging covers up the other document.
To tile documents in a Figure panel, Help browser, or web browser, on the right side of the title bar of
the tool, select the , , , or option button.
2-20
Change Desktop Layout
If you alternate between two or more customized desktop layouts, you can save them all to easily
switch between them. To save a layout, on the Home tab, in the Environment section, click Layout,
and select Save Layout (or Save Current Layout in MATLAB Online). MATLAB stores all saved
layouts in the preferences folder. MATLAB saves the current desktop layout at the end of a session in
the file MATLABDesktop.xml.
To use a saved layout, on the Home tab, click Layout, and select your saved layout. To delete or
rename saved layouts, select Organize Layouts. In MATLAB Online, right-click the layout and select
Delete or Rename from the context menu.
Some tools, such as the Help browser, web browser, and Variables editor, do not reopen automatically,
even if they were open when you ended the last session. You can use startup options to specify tools
that you want to open on startup. For more information, see “Specify Startup Options” on page 1-18.
See Also
Preferences
Related Examples
• “Customize MATLAB Toolbars” on page 2-12
• “Zoom and Change Desktop Fonts” on page 2-2
• “Change Desktop Colors” on page 2-7
2-21
2 Desktop
Accessibility in MATLAB
MATLAB provides several features to help make it accessible to users. To navigate MATLAB using just
a keyboard, you can use keyboard shortcuts. In MATLAB Online, you can use a screen reader and a
keyboard to interact with the different tools in MATLAB. Finally, to make the desktop more visible,
you can zoom in, change its colors, or increase the clarity of plots.
For our best accessibility support, use MATLAB Online. MathWorks is committed to improving the
accessibility of its software products, focusing first on the accessibility of MATLAB Online. See our
Accessibility Statement for MATLAB for the latest information on accessible workflow support.
In MATLAB Online, to move forward through the different areas of the MATLAB Online desktop, press
Ctrl+F6. To move backward, press Ctrl+Shift+F6. On macOS systems, use the Command key
instead of the Ctrl key. To display a list of navigational keyboard shortcuts, press Ctrl+/.
In an installed version of MATLAB, to move forward through the different areas of the MATLAB
desktop, press Ctrl+Tab. To move backward, press Ctrl+Shift+Tab. To select a toolstrip tab, press
Alt to show the access keys for the tabs and then <character> to select the tab, where
<character> is the displayed access key for the desired tab. After selecting a tab, press
<character> to select an item on the tab, where <character> is the displayed access key for the
desired toolstrip item. Accessing the toolstrip using keyboard shortcuts in an installed version of
MATLAB is not supported on macOS.
For more information, see “Use Keyboard Shortcuts to Navigate MATLAB” on page 2-28.
For example, on a Windows system with the NVDA screen reader and MATLAB Online running, enter
individual statements in the Command Window.
1 With the cursor in the Command Window, create a variable named x by entering this statement
in the Command Window.
x = 1
MATLAB adds x to the workspace and displays the results in the Command Window. You hear:
Greater greater
X equals one
When you hear Greater greater, the Command Window is ready for the next statement at the
command-line prompt (>>).
2-22
Accessibility in MATLAB
2 Create another variable y by entering the following statement in the Command Window.
y = cos(x)
clc
You hear:
Greater greater
For more information, see “Use a Screen Reader in MATLAB Online” on page 2-33.
Zoom
You can adjust the zoom level in MATLAB. The way you zoom differs depending on whether you are
using MATLAB Online or an installed version of MATLAB.
In MATLAB Online, you can zoom in and out of the entire desktop by adjusting the zoom settings for
your web browser.
In an installed version of MATLAB, you can change the zoom level in the Editor, Live Editor, and Help
browser. To zoom in and out, hold the Ctrl key and move the scroll wheel. On macOS systems, use the
Command key instead.
Alternatively, you can zoom in and out using the available keyboard shortcuts.
For tools such as the Command Window, Current Folder browser, and Workspace browser, you can
increase or decrease the displayed font size using font preferences. For more information, see “Zoom
and Change Desktop Fonts” on page 2-2.
To maximize the space for your current area of focus when zooming, minimize the tools that you are
currently not using. In MATLAB Online, to minimize a tool, click its icon in the sidebar. For example,
2-23
2 Desktop
if the MATLAB Online desktop is in the default layout with the Files panel and Workspace panel open
in the left sidebar, you can hide both tools by clicking the icon group for the two tools. If the left or
right sidebar contains multiple tools, you can minimize an individual tool by clicking the Collapse
button to the left of its title bar.
In an installed version of MATLAB, to minimize tools such as the Current Folder browser, Command
Window, Editor, and Live Editor, on the title bar of the tool, click the action menu button and select
Minimize. For example, to minimize the Current Folder browser, at top right of the Current Folder
browser, click the action menu button and select Minimize.
For more information about minimizing tools, see “Change Desktop Layout” on page 2-14.
1 In the Command Window, type preferences Colors to open the Preferences window with the
MATLAB Colors Preferences page selected.
2 In the Desktop tool colors section, clear the Use system colors check box.
In MATLAB Online, the Use system colors check box is not available and this step can be
skipped.
3 Use the Text and Background fields to change the colors. For example, select white for the text
color and black for the background color.
The Syntax Highlighting sample and Command Window sample areas show a preview of the
selected colors.
2-24
Accessibility in MATLAB
To restore the default text and background colors, click the Restore Default Colors button at the
bottom of the Preferences window.
In MATLAB Online, you also can use themes to change the colors of the MATLAB desktop.
To select a theme:
1 In the Command Window, type preferences Appearance to open the Preferences window
with the MATLAB Appearances Preferences page selected.
2 Select a MATLAB Theme. For example, select a dark theme.
For more information about the different ways to change the desktop colors in MATLAB, see “Change
Desktop Colors” on page 2-7.
Add contrast between the two lines and make them more visible using the LineWidth, Marker,
MarkerEdgeColor, and MarkerSize properties. For more information, see Line Properties.
2-25
2 Desktop
p(1).LineWidth = 2;
p(1).Marker = "*";
p(1).MarkerEdgeColor = "b";
p(1).MarkerSize = 8;
p(2).LineWidth = 3;
You also can use the fontsize function to change the font size for objects in a plot. For example,
increase the font size of the title, legend, and axes labels in the plot until they are more easily
readable.
fontsize(gcf,"increase")
fontsize(gcf,"increase")
fontsize(gcf,"increase")
2-26
Accessibility in MATLAB
See Also
matlab.fonts
Related Examples
• “Use Keyboard Shortcuts to Navigate MATLAB” on page 2-28
• “Use a Screen Reader in MATLAB Online” on page 2-33
• “Zoom and Change Desktop Fonts” on page 2-2
• “Change Desktop Colors” on page 2-7
• Accessibility Statement for MATLAB
2-27
2 Desktop
Installed MATLAB
If you have MATLAB installed on your system, this table describes the actions and related keyboard
shortcuts useful for navigating MATLAB without a mouse.
2-28
Use Keyboard Shortcuts to Navigate MATLAB
You cannot customize most of these shortcuts. For information about customizable keyboard
shortcuts and how to view and modify them, see “Customize Keyboard Shortcuts” on page 2-42.
MATLAB Online
MATLAB Online provides access to MATLAB from a standard web browser. Because MATLAB Online
runs in a browser, navigation using the keyboard is slightly different.
This table describes the actions and related keyboard shortcuts useful for navigating MATLAB Online
without a mouse.
2-29
2 Desktop
This table describes the actions and related keyboard shortcuts useful for navigating figures in
MATLAB Online without a mouse.
2-30
Use Keyboard Shortcuts to Navigate MATLAB
When focus is on the figure, this means Tab steps into the
axes. If there are multiple axes in a figure, and focus is on
the first axes, then Tab steps to the next axes.
Reverse Navigation Shift+Tab
This table describes several of these actions and their related keyboard shortcuts. For additional
keyboard shortcuts, see the documentation for a specific tool or feature.
For example, if you click the name of the Edit menu, the
whole menu appears. Pressing Esc hides the menu again.
You cannot customize these shortcuts. For information about customizable keyboard shortcuts and
how to view and modify them, see “Customize Keyboard Shortcuts” on page 2-42.
2-31
2 Desktop
See Also
More About
• “Customize Keyboard Shortcuts” on page 2-42
• “Rerun Favorite Commands” on page 3-14
• “Customize MATLAB Toolbars” on page 2-12
• “Accessibility in MATLAB” on page 2-22
2-32
Use a Screen Reader in MATLAB Online
To improve the screen reader experience when working in the Command Window, suppress excess
blank lines in output for the current session using the format command.
format compact;
To maintain the compact format across all future sessions, use settings to set the personal value for
line spacing in output display.
s = settings;
s.matlab.commandwindow.DisplayLineSpacing.PersonalValue = 'compact';
When working with graphics objects, avoid using the Property Inspector to view and modify
properties. Instead, view and modify graphics object properties programmatically. For example, the
plot function returns a chart line object. You can use dot notation to view and set properties.
p = plot(1:10,1:10);
p.LineWidth = 3;
Alternatively, you can set properties using name-value arguments when creating the object, such as
plot(1:10,1:10,'LineWidth',3).
For more information about viewing and modifying graphics object properties, see “Modify Graphics
Objects”.
To ensure the best experience when viewing and searching the documentation using a screen reader,
open it in a separate browser tab or window at https://www.mathworks.com/help/.
If you run MATLAB without the desktop using the -nodesktop start-up option, these tips can help
improve your screen reader experience:
• Use the format function to suppress excess blank lines in output, making it easier to navigate
diary files. For more information, see “Reduce Blank Lines in Output” on page 2-33.
• Include a filename when calling the diary function to save the Command Window text to a
separate file. You can call the diary function multiple times during a MATLAB session with
different filenames to save different sets of text to different files.
2-33
2 Desktop
For a more accessible alternative to using MATLAB with the -nodesktop option, use the Command
Window Only layout in MATLAB Online instead. Using the Command Window Only layout in MATLAB
Online gives you access to more keyboard shortcuts and, when needed, the full functionality of the
MATLAB desktop. To select the Command Window Only layout in MATLAB Online, go to the Home
tab, and in the Environment section, click the Layout button and then select Command Window
Only.
To move forward through the different areas of the MATLAB Online desktop, press Ctrl+F6 (or
Command+F6 on macOS systems). To move backward, press Ctrl+Shift+F6 (or Command+Shift
+F6 on macOS systems). You also can use a keyboard shortcut to navigate directly to some open
tools.
This table describes the different areas of the MATLAB Online desktop and their default positions.
2-34
Use a Screen Reader in MATLAB Online
For example, you can use the toolstrip to send feedback about the current release:
1 On a Windows system with the NVDA screen reader running, open a Google Chrome browser and
start MATLAB Online.
2 With the cursor in the Command Window, press Ctrl+F6 to navigate to the toolstrip. You hear:
Toolstrip region
Toolstrip tab control
Home tab selected one of three
3 Press the Tab key to enter the Home tab and then continue pressing the Tab key until you reach
the Feedback button. You hear:
Feedback button
Send us feedback or report a bug
4 Press Enter. The Send Feedback dialog box opens.
For more information about the MATLAB desktop, see “Change Desktop Layout” on page 2-14.
For example:
1 On a Windows system with the NVDA screen reader running, open a Google Chrome browser and
start MATLAB Online.
2 If the cursor is not in the Command Window, press Ctrl+0 (or Command+0 on macOS systems)
to navigate to the Command Window. You hear:
Command Window region
Command Window edit multiline
Greater greater
3 Create a variable named x by typing this statement in the Command Window.
x = 1
MATLAB adds x to the workspace and displays the results in the Command Window. You hear:
Greater greater
X equals one
When you hear Greater greater, the Command Window is ready for the next statement at the
command-line prompt (>>).
4 Create another variable y by entering the following statement in the Command Window.
y = cos(x)
You hear:
2-35
2 Desktop
x = y
You hear:
save test.mat
Greater greater
7 Remove the variables from the workspace by entering the following statement in the Command
Window.
clear
You hear:
Greater greater
8 Clear all text from the Command Window by entering the following statement in the Command
Window.
clc
You hear:
Greater greater
For more information about entering statements in the Command Window, see “Enter Statements in
Command Window” on page 3-2.
You can create and run scripts using a screen reader and a keyboard.
1 On a Windows system with the NVDA screen reader running, open a Google Chrome browser and
start MATLAB Online.
2 Navigate to the toolstrip by typing Ctrl+F6 until you hear:
2-36
Use a Screen Reader in MATLAB Online
Toolstrip region
Toolstrip tab control
Home tab selected one of three
3 Press the Tab key to enter the Home tab. The New Script button is selected. You hear:
Home property page
File grouping
New script button
Create a new script in the current folder
4 Press Enter to create a new script. MATLAB creates the script and opens it in the Editor. You
hear:
n = 50;
r = rand(n,1);
sz = size(r)
m = mean(r)
6 Type Ctrl+S to save the file. MATLAB opens the Save As dialog box. You hear:
Save as dialog
Edit untitled.m
Alternatively, you can open the Save As dialog box using the Save button on the toolstrip.
7 Type Ctrl+A to select the default file name and then enter a name for the script. For example,
enter the name myrandom.m. Press Enter to save the file.
8 To run the script, make sure that focus is inside the script, and then press F5. If focus is not
inside the script, pressing F5 reloads MATLAB Online in the browser.
MATLAB runs the script and displays the output in the Command Window. You hear:
Alternatively, you can run the script using the Run button on the toolstrip.
You can open and edit scripts using a screen reader and a keyboard.
1 On a Windows system with the NVDA screen reader running, open a Google Chrome browser and
start MATLAB Online.
2 If the cursor is not in the Command Window, press Ctrl+0 (or Command+0 on macOS systems)
to navigate to the Command Window. You hear:
2-37
2 Desktop
open myrandom.m
You hear:
Alternatively, you can open the script using the Open button on the toolstrip.
4 Use the arrow keys to navigate through the lines in the script and edit the code. For example, go
to line 4 in the code by pressing the Down Arrow key until you hear:
Line feed
6 Type a semi column (;) and save your changes by typing Ctrl+S.
Delete Scripts
You can delete scripts or other files or folders using a screen reader and a keyboard.
1 On a Windows system with the NVDA screen reader running, open a Google Chrome browser and
start MATLAB Online.
2 If the cursor is not in the Command Window, press Ctrl+0 (or Command+0 on macOS systems)
to navigate to the Command Window. You hear:
delete myrandom.m
You hear:
Greater greater
Alternatively, you can delete the script using the Files panel:
1 Press Ctrl+2 (or Command+2 on macOS systems) to navigate to the Files panel. You hear:
Files region
Table
2-38
Use a Screen Reader in MATLAB Online
For more information, see “Manage Files and Folders” on page 6-34.
For example:
On a Windows system with the NVDA screen reader running, open a Google Chrome browser and
start MATLAB Online.
1 If the cursor is not in the Command Window, press Ctrl+0 (or Command+0 on macOS systems)
to navigate to the Command Window. You hear:
x = 1:5
MATLAB adds x to the workspace and displays the results in the Command Window.
You hear:
Greater greater
X equals one two three four five
When you hear Greater greater, the Command Window is ready for the next statement at the
command-line prompt (>>).
3 Create another variable y by entering the following statement in the Command Window.
y = 2*x
You hear:
plot(x,y)
You hear:
2-39
2 Desktop
Figure 1
The current axes object contains one objects of type line
5 Bring the cursor back to the Command Window by pressing Ctrl+0 (or Command+0 on macOS
systems).
You hear:
title("My Plot")
legend
You hear:
Figure 1
The current axes object contains one objects of type line
7 Navigate to the new figure tab by typing Ctrl+F6 until you hear:
Tab control
Figure 1 tab selected
Figure 1, 1 of 1
8 Press Tab twice to select the figure axes.
You hear:
Figure 1
The current axes object contains one objects of type line
The axes object with title my plot contains one objects of type line
9 Type NVDA Modifier Key+Space to switch to focus mode for the figure axes. By default, the
NVDA Modifier Key is the Insert key.
10 Type Ctrl+Down Arrow to select the title inside the axes.
You hear:
Text my plot
11 Press Tab to select the line object. If axes contain multiple objects, press Tab to navigate
through them.
For more information about exploring plotted data, see “Interactively Explore Plotted Data”.
Limitations
Live Editor
Using a screen reader is not supported in the Live Editor. To create scripts and functions, use the
Editor instead.
2-40
Use a Screen Reader in MATLAB Online
See Also
More About
• “Use Keyboard Shortcuts to Navigate MATLAB” on page 2-28
• “Desktop Basics”
• “Accessibility in MATLAB” on page 2-22
2-41
2 Desktop
Keyboard shortcuts are useful for accessing desktop features quickly. To optimize your experience,
you can customize the current set of keyboard shortcuts in MATLAB.
There are several ways you can modify the current set of keyboard shortcuts. You can:
To view or modify the current set of keyboard shortcuts, use the Keyboard Shortcuts Preferences
options in the Preferences Window. To open the Keyboard Shortcuts Preferences page in the
Preferences Window, go to the Home tab, and in the Environment section, click Preferences.
Then, select MATLAB > Keyboard > Shortcuts.
For actions that are not performed with a menu item, to find keyboard shortcuts, open the Keyboard
Shortcuts Preferences page in the Preferences Window. Then, in the search box, enter the name of
the tool or action for which you want to see the keyboard shortcuts. For example, type Editor
clear to find the keyboard shortcut for clearing selected text in the Editor.
To view the shortcuts for an action, select the action name. For example, select Clear Selection.
MATLAB displays the keyboard shortcuts for the selected action. For example, the keyboard shortcut
for the Clear Selection action in the Editor is the Escape key.
2-42
Customize Keyboard Shortcuts
You can create a list of all the keyboard shortcuts in the current set by copying them to the clipboard
and pasting them in a text file or spreadsheet application, such as Microsoft Excel®. For the best
formatting, use a spreadsheet application. To copy all the keyboard shortcuts, open the Keyboard
Shortcuts Preferences page in the Preferences Window. Click the Actions button and from the
drop-down menu, choose Copy to Clipboard. Paste the data into the desired application.
Customizing a keyboard shortcut is useful if you frequently perform an action and the action does not
have a keyboard shortcut defined, or if the defined keyboard shortcut is hard to use or conflicts with a
different shortcut. For an overview on customizing keyboard shortcuts, watch the Customizable
Keyboard Shortcuts video. You must have an internet connection to watch the video.
1 Open the Keyboard Shortcuts Preferences page in the Preferences Window and, in the search
box, type an existing keyboard shortcut or the name of an action, tool, or menu.
For example, you can type Ctrl+R (shortcut), Delete (action), Command Window (tool), or File
(menu).
You can enter most keyboard shortcuts by either pressing keystrokes or typing the key names. If
using keystrokes for a keyboard shortcut does not work, try typing the key names instead. For
example, if pressing the Ctrl key and then R does not work, try typing the text Ctrl+R.
MATLAB displays the list of matching actions for which you can customize or define a keyboard
shortcut. If you specify the name of a tool, MATLAB displays actions associated with the tool or
menu, as well as any action names that contain the specified text.
2 Select the name of the action for which you want to define or modify a keyboard shortcut.
3
Click the Add button .
2-43
2 Desktop
4 Specify the keystrokes you want to use for the keyboard shortcut.
A keystroke can be a single key or the combination of a modifier (Alt, Shift, or Ctrl) and another
key. Specify a keystroke by performing it, not by typing the names of the keys character by
character. For example, press the Ctrl key and the Y key. Do not type C-t-r-l-+-Y.
To specify multiple keystrokes for one action, or to limit the number of keystrokes for an action,
click the down arrow next to the key icon in the Shortcuts box. Then, select either Limit to
1 keystroke, Limit to 2 keystrokes, or Limit to 3 keystrokes. For example, to
specify Ctrl+Y, Shift+Z, F9 as the three keystrokes for an action, select Limit to 3
keystrokes and then type the keystrokes.
5 In the Tools with shortcut column, click the down arrow and select which tools you want to
assign the keyboard shortcut to.
6 Evaluate and resolve any conflicts, indicated by the error icon and informational icon . The
error icon indicates that two different actions within the same tool have the same shortcut.
The informational icon indicates that two different actions in two different tools have the same
shortcut.
There is no requirement to resolve keyboard shortcut conflicts. However, if the same shortcut
specifies two different actions, the shortcuts can be confusing to use. Resolving all conflicts
indicated by the error icon is recommended, although in some situations, resolving a conflict
might be unnecessary. For example, resolving the conflict might be unnecessary if the conflict is
temporary or the two actions are associated with different modes of the same tool. Resolving
conflicts indicated by the informational icon is recommended if you use both tools frequently
and you perform both actions frequently.
To resolve a conflict, change or delete shortcuts such that there is a one-to-one correspondence
between shortcuts and frequently used actions.
7 Click OK or Apply.
New or modified keyboard shortcuts become available immediately. Changed shortcuts that
correspond to menu items immediately appear in the menu.
To delete a keyboard shortcut for a selected action, select the keyboard shortcut that you want to
delete and click the Delete button .
2-44
Customize Keyboard Shortcuts
If you modify keyboard shortcuts, and then decide you do not want to keep the changes, you can
restore the default shortcuts. To restore the default state of a keyboard shortcut, click the Actions
button and select Undo Modifications to <Set Name> Default Set (modified), where <Set
Name> is the name of the modified default set.
Note Undoing modifications reverts all keyboard shortcuts changes that you made to the set. You
cannot undo modifications on a shortcut-by-shortcut basis.
There are some actions and tools for which you cannot change the keyboard shortcuts. Actions for
which the keyboard shortcut cannot be customized do not appear when you search for them in the
Keyboard Shortcuts Preferences page in the Preferences Window. Examples of these actions
include canceling the current action (Esc), interrupting MATLAB execution (Ctrl+C), and some of the
navigational actions described in “Use Keyboard Shortcuts to Navigate MATLAB” on page 2-28.
In addition, you cannot change the keyboard shortcuts associated with these tools or portions of
tools:
• Figure windows — For example, you cannot modify the keyboard shortcut, Ctrl+S, for saving a
MATLAB .fig file.
• Toolboxes — For example, you cannot modify keyboard shortcuts in the SimBiology® desktop.
• Incremental search — You can modify the keyboard shortcuts for initiating a forward or backward
incremental search. However, you cannot change the keyboard shortcuts that you use within
incremental search mode, such as Ctrl+Shift+S to search forward.
• Dialog boxes — For example, you cannot create a keyboard shortcut for the OK button.
By default, MATLAB uses the keyboard shortcut settings for your current platform. To select a
different set of keyboard shortcuts, open the Keyboard Shortcuts Preferences page in the
Preferences Window and, in Active settings, select from the available options. To use a keyboard
shortcut settings file that is on your system but not in the Active settings list, select Browse... to
find and select the desired file.
This table lists the keyboard shortcut settings files installed with MATLAB.
2-45
2 Desktop
You also can download keyboard shortcut settings files from File Exchange. For example, to restore
the MATLAB default keyboard shortcuts that were in place for MATLAB Version 7.9 (R2009a) and
earlier releases, go to File Exchange and search for MATLAB Desktop R2009a Default
Keyboard Shortcut sets. Download and extract the set and then select it as the active settings
file. A valid keyboard shortcut settings file appears with a keyboard key icon .
1 Open the Keyboard Shortcuts Preferences page in the Preferences Window and click the
Actions button .
2 From the drop-down menu, choose the set of keyboard shortcuts to which you want to compare
the current set.
3 The Comparison Tool opens and displays the two keyboard shortcut sets side-by-side. For more
information about how to read the results, see “Compare Text Files” on page 6-11.
Saving a set of keyboard shortcuts to a settings file is useful if you want to:
• Save the changes you make to a default keyboard shortcut set to a new set.
• Use a set of customized keyboard shortcuts on another system running MATLAB.
• Overwrite a previously saved set of keyboard shortcuts.
• Share a set of keyboard shortcuts with others, for example, on File Exchange.
To save a keyboard shortcut settings file, open the Keyboard Shortcuts Preferences page in the
Preferences Window. Then, click the Actions button and select Save As. MATLAB saves the file
as an .xml file in the folder that you specify.
You cannot overwrite the default settings files that install with MATLAB. MATLAB saves modifications
that you make to a default set using the name of the default set appended with the text (modified),
for instance, Windows default (modified).
To delete a previously saved set of keyboard shortcuts, open the Keyboard Shortcuts Preferences
page in the Preferences Window and in Active settings, select the set of keyboard shortcuts that you
want to delete. Click the Actions button and select Delete filename, where filename is the
name of a keyboard shortcut set you want to delete. You cannot delete default keyboard shortcut sets,
such as Windows Default Set.
See Also
More About
• “Use Keyboard Shortcuts to Navigate MATLAB” on page 2-28
• “Rerun Favorite Commands” on page 3-14
• “Customize MATLAB Toolbars” on page 2-12
2-46
Set Print Options for Command Window and Editor
You can customize how pages look when printing from the Command Window and Editor.
To specify page setup options, open the Page Setup dialog box using one of these methods:
• Command Window — Right-click in the Command Window and select Page Setup.
• Editor — Go to the Editor tab, and in the File section, select Print > Page Setup.
The Live Editor has a different way of controlling how pages look when printing. To change the page
setup options when exporting in the Live Editor, use settings. For more information, see the
matlab.editor.export settings described in matlab.editor.
Add Header
When printing from the Command Window or Editor, you can include a header on each printed page.
The header includes information such as the current date and time, the name of the file you are
2-47
2 Desktop
printing, and the page number. To include a header, in the Page Setup dialog box, select the Layout
tab and then select Print header.
To change the format and layout of the header, select the Header tab and then select from the
available options, as described in the table below. (On macOS platforms, select MATLAB in the
Settings menu to see the Header tab.) The preview area shows a sample of the header with the
selected options.
For example, in the Editor, print the example file fourier_demo2.m with a standard two line header
and a double line border.
2-48
Set Print Options for Command Window and Editor
Change Fonts
You can specify the font to use when printing. By default, MATLAB uses the Editor or Command
Window font when printing.
1 In the Page Setup dialog box, select the Fonts tab. (On macOS platforms, select MATLAB in the
Settings menu to see the Fonts tab.)
2 In the Choose font field, select Header to change the font for the header text, or Body to
change the font for all of text in Command Window or Editor except for header text.
3 Select Use custom font and then specify the font name, style, and size. The Sample area shows
a preview of the selected font.
See Also
print | matlab.editor
Related Examples
• “Print Figure from File Menu”
• “Zoom and Change Desktop Fonts” on page 2-2
• “Change Desktop Colors” on page 2-7
2-49
2 Desktop
In this section...
“About Web Browsers and MATLAB” on page 2-50
“Specify Proxy Server Settings for Connecting to the Internet” on page 2-52
“Specify the System Browser for Linux Platforms” on page 2-52
2-50
Web Browsers and MATLAB
The MATLAB Web and Help browsers may not support all the features that a particular Web site or
HTML page uses. For example, the MATLAB Web browser does not display .bmp (bitmap) image files.
Instead use .gif or .jpeg formats for image files in HTML pages.
To display an HTML document in the MATLAB Web browser, double-click the document name in the
Current Folder browser.
System Browser
• On Microsoft Windows and Apple Macintosh platforms, MATLAB uses the default browser for your
operating system.
• On UNIX® platforms, MATLAB uses the Mozilla Firefox browser. You can specify a different system
browser for MATLAB using Web preferences on page 2-52.
2-51
2 Desktop
• MATLAB supports non-authenticated, basic, digest, and NTLM proxy authentication types.
• If a proxy with basic authentication is specified, MATLAB only supports HTTP connections. HTTPS
connections are not supported.
• You cannot specify the proxy server settings using a script.
• There is no automated way to provide the proxy server settings your system browser uses to
MATLAB.
1 On the Home tab, in the Environment section, click Preferences. Select MATLAB > Web.
2 Select the Use a proxy server to connect to the Internet check box.
3 Specify values for Proxy host and Proxy port.
Examples of acceptable formats for the host are: 172.16.10.8 and ourproxy. For the port,
enter an integer only, such as 22. If you do not know the values for your proxy server, ask your
system or network administrator for the information.
If your proxy server requires a user name and password, select the Use a proxy with
authentication check box. Then enter your proxy user name and password.
4 Ensure that your settings work by clicking the Test connection button.
• If MATLAB can access the Internet, Success! appears next to the button.
• If MATLAB cannot access the Internet, Failed! appears next to the button. Correct the values
you entered and try again. If you still cannot connect, try using the values you used when you
authenticated your MATLAB license.
5 Click OK to accept the changes.
6 Restart MATLAB to enable the changes.
1 On the Home tab, in the Environment section, click Preferences. Select MATLAB > Web.
2 Under System Web browser, in the Command field, specify the system command to open the
browser, for example, opera, which opens the Opera Web browser.
3 Add options for opening your system browser in the Options field. For example, geometry
1064x860 specifies the size of the window for Opera.
4 Click OK.
Note If you specify Firefox as the system browser using the system command firefox, specify a
display option to ensure that the browser opens correctly.
2-52
Web Browsers and MATLAB
See Also
web
More About
• “Web Preferences” on page 2-64
2-53
2 Desktop
Note Some options for license actions require an internet connection. If your internet connection
requires a proxy server, use MATLAB web preferences to specify the server host and port. See
“Specify Proxy Server Settings for Connecting to the Internet” on page 2-52 for more information.
MATLAB displays a list of all your MathWorks licenses on this computer, with
their status. When you select a license and click Update, MATLAB contacts
MathWorks to retrieve the most current version of the License File for the
license. The update process overwrites the current License File on your
system. You need to restart MATLAB.
MathWorks Account 1 Sign in to mathworks.com. If you are already signed in, select My
Account from the drop-down menu under your account icon.
2 Under My Software, click the license you want to update. If you have
more licenses than fit on the screen, click View additional Licenses or
Trials and then click the license you want. Clicking a license takes you to
the License Center.
3 In the License Center, click the Install and Activate tab.
4 Click Update License File.
5 Click one of the icons under Get License File. You can download the
license file or have it emailed to you.
6 Follow all prompts.
MathWorks retrieves the most current version of the License File for the
license. You need to restart MATLAB.
Activate Software
The simplest way to activate your software is from within MATLAB. You should perform this task
within your MathWorks Account only if your computer cannot communicate with MathWorks. For
additional details on activation, see “Activate MATLAB Installation Manually”.
2-54
Manage Your Licenses
MATLAB starts the activation application, which walks you through the
activation process. Answer the questions on each dialog box, select the license
you want to activate, and click Activate.
MathWorks Account 1 Sign in to mathworks.com. If you are already signed in, select My
Account from the drop-down menu under your account icon.
2 Under My Software, click the license you want to activate. If you have
more licenses than fit on the screen, click View additional Licenses or
Trials, and then click the license you want.
3 Click the Install and Activate tab.
4 Click Activate to Retrieve License File or Activate a Computer.
5 Follow all prompts.
Deactivate Software
Although you can deactivate the software from within MATLAB, if you cannot access the computer to
deactivate, you can still deactivate the software from your MathWorks Account.
For more details on deactivating MathWorks software, see “Deactivate Your Installation”.
MATLAB displays a list of all your MathWorks licenses on this computer, with
their status. When you select a license and click Deactivate, MATLAB
deactivates all releases on this computer associated with the license, and
updates the licensing information at the MathWorks website. You will not be
able to use MathWorks software with that license on this computer.
If you are not connected to the Internet, MATLAB deactivates the licenses on
your computer but cannot update the corresponding license information stored
at the MathWorks website. In this scenario, MATLAB returns a deactivation
string. To complete deactivation, save a copy of this string, go to a computer
with an internet connection, and visit the License Center at the MathWorks
website. There you can sign in to your MathWorks Account and enter the
deactivation string.
2-55
2 Desktop
MathWorks deactivates all releases on the specified computer, and updates the
licensing information in License Center.
If you are linking a network license, you may need to get the license number
from your organization's license administrator.
Get a Trial
Start a free 30-day trial of MathWorks software.
Although you can get a trial from within MATLAB or from your MathWorks Account, the simplest way
is to go directly to Free MATLAB Trial on mathworks.com.
See Also
license
2-56
Manage Your Licenses
Related Examples
• “Install Products”
• “Manage Products”
• “Administer Network Licenses”
2-57
2 Desktop
If a more recent version is available, a notification displays in MATLAB when you start the program.
To install the MATLAB update, click the notification icon and then select Install Update. If you click
the notification but decide not to install the update, the notification is cleared; however, you can still
install the update at a later time.
You also can check for updates manually. You must have an active internet connection to check for
and update your installation.
On the Home tab, click Help > Check for Updates. The Add-On Manager opens with the Updates
tab selected. If there is an update available for your version of MATLAB, click the Update button to
the right of the update name to install it. If there is no update available for your version or if you have
already installed the latest update, MATLAB displays that information.
In R2019a: On the Home tab, click Help > Check for Updates > Products. If there is an update
available, click Install Update.
Before R2019a: On the Home tab, click Add-Ons > Check for Updates > Products.
See Also
More About
• “Get New MATLAB Release”
• “Get and Manage Add-Ons” on page 8-2
2-58
macOS Platform Conventions
Make the following replacements to adjust documented mouse instructions for Macintosh platforms if
you are using a one-button mouse:
To view the contents of the MATLAB root folder in the Mac Finder, right-click the MATLAB
application bundle, and then select Show Package Contents from the context menu.
To view the content of the MATLAB root folder from within MATLAB:
1
On the Home tab, in the File section, click
2 In the File Browser dialog box, press Command+Shift+G to open the Go To Folder dialog box.
3 Enter the full path to a folder within the MATLAB application package, for example, /
Applications/MATLAB_R2019a.app/bin.
4 Press Go.
To open a file with a MATLAB command, such as edit, specify the full path of the MATLAB root
folder. For example:
edit(fullfile(matlabroot,'/toolbox/matlab/demos/lotka.m'))
2-59
2 Desktop
of MATLAB to start additional instances rather than trying to keep multiple MATLAB icons in the
Dock.
2-60
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 release R2016b, the name of
the preferences folder is R2016b.
On macOS and iOS, the preferences folder might be inside another folder that is hidden. If so, to
access the hidden folder:
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.
If you make changes to preferences while MATLAB is using the temporary preferences folder, the
preferences persist across sessions. But, once the issue is resolved that was preventing MATLAB from
accessing the preferences folder, any changes made to the preferences while using the temporary
preferences 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.
See Also
prefdir | Preferences
Related Examples
• “Import Preferences From Other Releases” on page 2-62
2-61
2 Desktop
• MATLAB looks for a preferences folder for release R2019b or newer. If MATLAB finds one or more
preferences folders matching that criteria, it migrates the files from the most recent version.
For example, if you start R2021b and preferences folders exist for both the R2020b and R2019b
releases, then MATLAB migrates the files from the R2020b preferences folder to the R2021b
preferences folder.
Note For releases before R2021b, MATLAB looks back three releases. For example, if you start
R2019a, MATLAB looks for preferences from R2018b, R2018a, and R2017b.
• If a preferences folder does not exist from a valid previous release, then MATLAB creates the
default preference files for the release starting up.
For example, if you start R2021a, MATLAB looks for preferences for versions R2020b, R2020a,
and R2019b. If none of those is installed, MATLAB creates the default files for the R2021a release.
This is true even if a preferences folder exists for the R2019a release or earlier.
• If you install a release older than the current version, MATLAB does not import preferences from
releases that are newer than that release.
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 you are running. For example, for
MATLAB R2021a, the name of the preferences folder is R2021a.
prefdir
ans =
'C:\Users\username\AppData\Roaming\MathWorks\MATLAB\R2021a'
On macOS and iOS, the preferences folder might be inside another folder that is hidden. If so, to
access the hidden folder:
1 In the Finder, select Go > Go to Folder.
2 In the resulting dialog box, type the path returned by prefdir, and then press Enter.
For example, to use the default preferences for R2021a, start MATLAB, and in the Command Window,
type prefdir to determine the location of the preferences folder.
prefdir
ans =
'C:\Users\username\AppData\Roaming\MathWorks\MATLAB\R2021a'
2-62
Import Preferences From Other Releases
Alternatively, if you have not started the new release yet, create an empty preferences folder for it.
This will prevent MATLAB from importing preferences when you do open the new release, and force
it to use the default preferences instead. For example, to use the default preferences for MATLAB
R2021a, if your MATLAB preferences are stored in the C:\Users\username\AppData\Roaming
\MathWorks\MATLAB folder, create the folder C:\Users\username\AppData\Roaming
\MathWorks\MATLAB\R2021a.
See Also
prefdir | Preferences
Related Examples
• “Where MATLAB Stores Preferences” on page 2-61
2-63
2 Desktop
Web Preferences
Limitations
• MATLAB supports nonauthenticated, basic, digest, and NTLM proxy authentication types.
• You cannot specify proxy server settings using a script.
• There is no automated way to provide MATLAB with the proxy server settings that your system
browser uses.
You can set Web preferences on the Home tab, in the Environment section. Click Preferences.
Select MATLAB > Web, and then adjust preference options as described in this table.
Preference Usage
Use a proxy server to connect to Provide information that MATLAB needs to access the Internet when your
the Internet network uses a firewall or another method of protection that restricts
internet access.
Proxy host Specify a value for the Proxy host. For example, 172.16.10.8 or
ourproxy. If you do not know the values for your proxy server, ask your
system or network administrator for the information.
Proxy port Specify an integer value for the Proxy port. For example, 22. If you do
not know the values for your proxy server, ask your system or network
administrator for the information.
Use a proxy with authentication Specifies that your proxy server requires a user name and password.
Proxy username Specify the proxy server user name.
Proxy password Specify the proxy server password.
Test connection Ensure that your settings work.
Specify the system Command to use to open the system browser. For
example, opera, opens the Opera Web browser.
Specify the Options to use for the system browser. For example,
geometry 1064x860 specifies the size of the window for Opera.
If you specify Firefox as the system browser using the system command
firefox, specify a display option to ensure that the browser opens
correctly.
2-64
3
Entering Commands
As you work in MATLAB, you can enter individual statements in the Command Window. For example,
create a variable named a by typing this statement at the command line:
a = 1
MATLAB immediately adds variable a to the workspace and displays the result in the Command
Window.
a =
When you do not specify an output variable, MATLAB uses the variable ans, short for answer, to
store the results of your calculation.
sin(a)
ans =
0.8415
The value of ans changes with every command that returns an output value that is not assigned to a
variable.
If you end a statement with a semicolon, MATLAB performs the computation, but suppresses the
display of output in the Command Window.
b = 2;
To enter multiple statements on multiple lines before running any of the statements, use Shift+Enter
between statements. This action is unnecessary when you enter a paired keyword statement on
multiple lines, such as for and end.
You also can enter more than one statement on the same line by separating statements. To distinguish
between commands, end each one with a comma or semicolon. Commands that end with a comma
display their results, while commands that end with a semicolon do not. For example, enter the
following three statements at the command line:
A =
17 24 1 8 15
23 5 7 14 16
4 6 13 20 22
10 12 19 21 3
11 18 25 2 9
C =
3.6170 5.1064 0.2128 1.7021 3.1915
4.8936 1.0638 1.4894 2.9787 3.4043
0.8511 1.2766 2.7660 4.2553 4.6809
2.1277 2.5532 4.0426 4.4681 0.6383
2.3404 3.8298 5.3191 0.4255 1.9149
3-2
Enter Statements in Command Window
To recall previous lines in the Command Window, press the up- and down-arrow keys, ↑ and ↓. Press
the arrow keys either at an empty command line or after you type the first few characters of a
command. For example, to recall the command b = 2, type b, and then press the up-arrow key.
To clear a command from the Command Window without executing it, press the Escape (Esc) key.
You can evaluate any statement already in the Command Window. Select the statement, right-click,
and then select Evaluate Selection.
In the Command Window, you also can execute only a portion of the code currently at the command
prompt. To evaluate a portion of the entered code, select the code, and then press Enter.
hello
See Also
Command Window
Related Examples
• “Check Syntax as You Type” on page 3-20
• “Set Command Window Preferences” on page 3-16
3-3
3 Entering Commands
1
In the Command Window, click the Browse for functions button to the left of the prompt. The
Function browser opens.
Tip The Function browser closes when you move the pointer outside of it. To keep the browser
open, drag it by the top edge to a different location.
2 Optionally, select a subset of products to display in the list. Click the product area at the bottom
of the browser (where the text All installed products appears by default), and then set the
Selected Products preference and click OK. This preference also applies to the Help browser.
3 Find functions by browsing the list or by typing a search term. For example, search for the term
fourier.
3-4
Find Functions to Use
In the search results, a parenthetical term after a function name indicates either that the
function is in a product folder other than MATLAB, or that there are multiple functions with the
same name. For example, fft (comm) corresponds to the fft function in the Communications
Toolbox™ folder.
4 Select a function that you would like to use or learn more about, as follows.
• Insert the function name into the current window by double-clicking the name. Alternatively,
drag and drop the function name into any tool or application.
• View syntax information for the function by single-clicking its name. A brief description for
each of the syntax options displays in a yellow pop-up window.
Tip The pop-up window automatically closes when you move your pointer to a new item in the
results list. To keep the pop-up window open, drag it by the top edge to a different location.
3-5
3 Entering Commands
You can change the font that the Function browser uses by setting preferences. On the Home tab, in
the Environment section, select Preferences > Fonts. By default, the Function browser uses the
desktop text font and the pop-up window uses the Profiler font.
3-6
Format Output
Format Output
MATLAB displays output in both the Command Window and the Live Editor. You can format the
output display using several provided options.
x =
1.3333 0.0000
• compact — Suppresses the display of blank lines.
• On the Home tab, in the Environment section, click Preferences. Select MATLAB >
Command Window, and then choose a Line spacing option.
• Use the format function at the command line, for example:
format loose
format compact
For example, suppose that you enter x = [4/3 1.2345e-6] in the Command Window. The MATLAB
output display depends on the format you selected. This table shows some of the available numeric
display formats, and their corresponding output.
3-7
3 Entering Commands
Note The text display format affects only how numbers are shown, not how MATLAB computes, or
saves them.
• On the Home tab, in the Environment section, click Preferences. Select MATLAB >
Command Window, and then choose a Numeric format option.
• Use the format function, for example:
format short
format short e
format long
See the format reference page for a list and description of all supported numeric formats.
1 On the Home tab, in the Environment section, click Preferences. Select MATLAB >
Command Window.
2 Select Wrap Lines.
3 Click OK.
Suppress Output
To suppress code output, add a semicolon (;) to the end of a command. This is useful when code
generates large matrices.
Running the following code creates A, but does not show the resulting matrix in the Command
Window or the Live Editor:
A = magic(100);
Output in the Command Window might exceed the visible portion of the window. You can view the
output, one screen at a time:
3-8
Format Output
• On the Home tab, in the Code section, select Clear Commands > Command Window to clear
the Command Window scroll buffer.
• Use the clc function to clear the Command Window scroll buffer.
• Use the home function to clear your current view of the Command Window, without clearing the
scroll buffer.
See Also
clc | format | home | more
3-9
3 Entering Commands
Stop Execution
To stop execution of a MATLAB command, press Ctrl+C or Ctrl+Break.
On Apple Macintosh platforms, you also can use Command+. (the Command key and the period
key).
Ctrl+C does not always stop execution for files that run a long time, or that call built-ins or MEX-files
that run a long time. If you experience this problem, include a drawnow, pause, or getframe
function in your file, for example, within a large loop. Also, Ctrl+C might be less responsive if you
start MATLAB with the -nodesktop option.
Note For certain operations, stopping the program might generate errors in the Command Window.
To programmatically stop execution of a function or script before reaching the end, use the return
function. MATLAB returns control to the Command Window or the invoking function.
See Also
drawnow | getframe | pause | return
3-10
Find Text in Command Window or History
To search for specified text in the Command Window, on the Command Window title bar, click the
action button , and then select Find. The Find dialog box opens. The search begins at the current
cursor position. MATLAB finds the text you specified and highlights it.
MATLAB beeps when a search for Find Next reaches the end of the Command Window, or when a
search for Find Previous reaches the top of the Command Window. If you have Wrap around
selected, MATLAB continues searching after beeping.
To search for the specified text in other MATLAB desktop tools, change the selection in the Look in
field.
You can increase the amount of information available in the Command Window so that more text is
available for searching. Doing so requires more memory. On the Home tab, in the Environment
section, click Preferences. Select MATLAB > Command Window, and then increase the setting
for Number of lines in the command window scroll buffer.
Clearing the command window (for example, with the clc function), empties the scroll buffer. The
cleared text is no longer available for searching. To clear your display in the Command Window
without clearing the buffer, use the home function.
You can also perform an incremental search in the Command Window using keyboard shortcuts.
An incremental search field appears in the bottom right corner of the MATLAB Desktop window.
For a forward search, the text F Inc Search appears. The F indicates a forward search.
3-11
3 Entering Commands
When you enter lowercase letters in the incremental search field, MATLAB looks for both
lowercase and uppercase instances of the letters. For example, if you enter b, MATLAB looks for
b and B. However, if you enter uppercase letters, MATLAB only looks for instances that match the
case you entered.
3 Perform incremental search actions using these keyboard shortcuts:
If you search for a set of characters that does not appear in the Command Window text, Failing
appears in the incremental search field.
4 End incremental searching by pressing Esc (escape), Enter, or any other key that is not a
character or number.
The incremental search field disappears. The cursor remains at the position where the text was
last found, with the search text highlighted.
1 In the Command History window, type in the Search field. To display the Search field if it is not
visible, click the action button , and then select Find.
The Command History window searches backward and selects the previous entry that contains
the sequence of letters you typed.
3 Select from the different search options using the buttons to the right of the search field. Options
include Match case , Match anywhere within command , and Match at beginning of
command .
4 Find the previous or next occurrence of the entry with the up and down arrow keys, respectively.
5 Press Esc to clear the search.
In MATLAB Online, to search for text in the Command History window, click the Command History
icon in the sidebar and use the Search field to perform a search.
See Also
Command Window | Command History
3-12
Find Text in Command Window or History
Related Examples
• “Find and Replace Text in Files and Go to Location”
• “Find Files” on page 6-2
3-13
3 Entering Commands
MATLAB favorite commands (previously called command shortcuts) are an easy way to run a group of
MATLAB language statements that you use regularly. For example, you can use a favorite command to
set up your environment when you start working, or to set the same properties for figures you create.
To run a favorite command, on the Home tab, click Favorites and then click the icon for the desired
favorite command. All the statements in the Code field of the Favorite Command Editor execute as if
you ran those statements from the Command Window, although they do not appear in the Command
History window.
To edit a favorite command, click the Edit favorite command button to the right of the favorite
command. To delete a favorite command, click the Delete favorite command button to the right of
the favorite command. You also can right-click the favorite command and select Edit Favorite or
Delete Favorite.
3-14
Rerun Favorite Commands
You can organize your favorite commands by storing them in different categories.
1 On the Home tab, in the Code section, click Favorites and then click New Category. The
Favorite Category Editor dialog box opens.
2 In the Label field, enter a name for the category. For this example, enter My Favorite
Favorites.
3 In the Icon field, select an icon.
4 To add the category to the quick access toolbar, select both the Add to quick access toolbar
and Show label on quick access toolbar options.
5 Click Save.
To move a category up or down in the list of categories, or to move a favorite command within a
category, drag the category or favorite command to the desired location. You also can use the Move
category to top and Move category to bottom buttons to the right of the category.
To change whether a single category or favorite command appears in the quick access bar, click the
Add to quick access toolbar and Remove from quick access toolbar buttons to the right of the
category or favorite command. In MATLAB Online, right-click the category or command and select
Add to quick access toolbar. To add all favorite commands to the quick access bar, on the
Home tab, right-click Favorites and select Add to quick access toolbar.
To further configure which favorite commands and categories appear in the quick access bar, on the
Home tab, in the Code section, click Favorites and then click Quick Access. Configuring the
quick access bar is not supported in MATLAB Online.
See Also
More About
• “Customize Keyboard Shortcuts” on page 2-42
• “Set Command History Preferences” on page 3-25
3-15
3 Entering Commands
You can customize the visual display and behavior of the Command Window and the command output
within it using Command Window preferences.
On the Home tab, in the Environment section, click Preferences. Select MATLAB > Command
Window, and then adjust the options as described in this table.
Preference Usage
Text display Select a Numeric format option to specify the output format of numeric
values in the Command Window.
For details, see “Wrap Lines of Code to Fit Window Width” on page 3-8.
Select Set matrix display width to eighty columns to limit the width of
matrix output.
If you also select Wrap lines, and the width of the Command Window is fewer
than 80 characters, each row of 80 characters of matrix output wraps to fit
within the width of the Command Window.
Select Show getting started message bar to display the Command Window
message bar that provides links to introductory information.
3-16
Set Command Window Preferences
Preference Usage
Select Show function browser button to display the Browser for functions
button to the left of the prompt in the Command Window. You can use the
Function browser to search for MATLAB functions.
Select Suggest corrections for mistyped functions and variables to
display suggestions in the Command Window. If you enter an undefined
function, variable name, or MATLAB operator, MATLAB displays:
followed by a suggested command at the command line. You can press Enter
to execute that command or Esc to delete the suggestion.
Number of lines in command window scroll buffer specifies the maximum
number of lines displayed in the Command Window. A larger scroll buffer
provides a larger base for search features, but requires more memory. By
default, the scroll buffer is set to 5,000 lines.
The scroll buffer size does not impact the number of lines that you can recall.
By default, you can use the up arrow key ↑ to recall all lines shown in the
Command History window, regardless of how many lines you see in the
Command Window.
Tab key Tab size specifies the number of spaces assigned to the tab key.
This setting does not apply if you have enabled tab completion for the
Command Window or Editor. To enable or disable tab completion, on the
Home tab, select Preferences > Keyboard.
You can change how MATLAB suggests and completes names in the Command Window.
On the Home tab, in the Environment section, click Preferences. Select MATLAB > Command
Window > Automatic Completions, and then adjust the options as described in this table.
Preference Usage
Suggestions and completions Select Enable tab completion to suggest names when you type the first few
characters of the name and press the Tab key in the Command Window.
For more information, see “Check Syntax as You Type” on page 3-20.
Select Tab key narrows completions to continue to reduce the list of
suggestions as you type each additional character and press the Tab key.
For more information, see “Check Syntax as You Type” on page 3-20.
3-17
3 Entering Commands
Preference Usage
Select Enable function hints to display function syntax suggestions in the
Command Window.
When enabled, if you type a function name with an opening parenthesis, and
then pause, a tooltip opens showing the basic syntax information for the
function.
For more information, see “Check Syntax as You Type” on page 3-20.
In MATLAB Online, to show suggestions as you type in the Command Window, select Show
suggestions automatically. To show suggestions when you press the Tab key, select Use tab to
show suggestions (in addition to ctrl+space). To accept suggestions using the Right Arrow key,
select Use right arrow to accept suggestions (in addition to tab and enter).
See Also
More About
• “Check Syntax as You Type” on page 3-20
• “Set Keyboard Preferences” on page 3-19
• “Zoom and Change Desktop Fonts” on page 2-2
3-18
Set Keyboard Preferences
You can set delimiter matching options in the Command Window, Editor, and Live Editor.
On the Home tab, in the Environment section, click Preferences. Select MATLAB > Keyboard,
and then adjust the options as described in this table.
Preference Usage
Delimiter Matching Specify when and if MATLAB alerts you to matched and mismatched
delimiters. Delimiters include parentheses, brackets, braces, and, in the
Editor only, paired keywords.
Select Show matches and mismatches when typing for MATLAB to alert
you to matched and mismatched delimiters as you type.
Select Show matches and mismatches when using arrow keys for
MATLAB to alert you to matched and mismatched delimiters when you move
the cursor over a delimiter by using an arrow key.
See Also
Related Examples
• “Check Syntax as You Type” on page 3-20
• “Set Command Window Preferences” on page 3-16
3-19
3 Entering Commands
Syntax Highlighting
To help you identify MATLAB elements, some entries appear in different colors in the Command
Window, the Editor, and the Live Editor. This color display is known as syntax highlighting. By default:
Except for errors, output in the Command Window does not appear with syntax highlighting.
MATLAB software copies the selection to the clipboard in RTF format, which many Microsoft
Windows and macOS applications support. When you paste or drag a selection from the Editor and
Live Editor to another application, such as Microsoft Word, the pasted text maintains the syntax
highlighting colors and font characteristics from the Editor and Live Editor.
To change syntax highlighting preferences, on the Home tab, in the Environment section, click
Preferences. Then, select MATLAB > Editor/Debugger > Language and from the Language
drop-down list, choose a language. To change syntax highlighting preferences in MATLAB Online,
select Editor/Debugger > MATLAB Language or Editor/Debugger > Other Languages.
Delimiter Matching
MATLAB indicates matched and mismatched delimiters, such as parentheses, brackets, and braces, to
help you avoid syntax errors. MATLAB also indicates paired language keywords, such as for, if,
while, else, and end statements.
In the Editor and Live Editor, MATLAB indicates matching delimiters by briefly underlining both
delimiters in the pair. In the Command Window, matching delimiters are indicated by highlighting
instead of underlining. In MATLAB Online, the Command Window behavior matches the Editor and
Live Editor behavior.
MATLAB indicates mismatching delimiters in the Editor, Live Editor, and Command Window by briefly
crossing out the mismatched delimiter.
3-20
Check Syntax as You Type
If a matching delimiter exists, but it is not visible on the screen, a window opens and displays the line
containing the matching delimiter. Click in the window to go to that line.
You can change if and when MATLAB alerts you to matched and mismatched delimiters. On the
Home tab, in the Environment section, click Preferences. Select MATLAB > Keyboard and in
the Delimiter matching section, select from the available options.
When you write code in the Command Window, Editor, Live Editor, and App Designer, MATLAB shows
suggestions for the names of functions, models, MATLAB objects, files, folders, variables, structures,
graphics properties, parameters, and options. In addition, MATLAB shows basic syntax information
for functions. You can use these suggestions to write commands faster and avoid typographical
errors.
Name Suggestions
In the Editor, Live Editor, and App Designer, name suggestions appear as you type. You also can press
Ctrl+Space or the Tab key to show suggestions. MATLAB shows the first 100 name suggestions as
you type. To show new and more refined suggestions, continue typing.
To insert a suggestion in your code, use the arrow keys to select the name that you want, and then
press the Right Arrow, Tab, or Enter key to accept the suggestion. To clear the list of suggestions
without selecting anything, press the Esc key.
In the Command Window, name suggestions appear only after you press the Tab key. To show
suggestions, type the first few characters of the name that you want suggestions for, and then press
the Tab key. Use the arrow keys to select the name that you want, and then press the Tab key again
to accept the suggestion. In MATLAB Online, the Command Window also shows suggestions as you
type and when you press Ctrl+Space or the Tab key.
Name suggestions are useful when completing the names and values of graphics properties. For
example, plot(x,y,"LineStyle","-").
3-21
3 Entering Commands
You also can use suggestions to complete parameter names and options for certain functions. For
example, format("shortEng").
MATLAB does not complete field names of structure arrays defined only within the active document.
Tip To insert a tab within a statement when suggestions and completions are enabled in the Editor,
Live Editor, and App Designer, first, add a space. Then, press the Tab key. Alternatively, go to the
Home tab, and in the Environment section, click Preferences. Select MATLAB > Editor/
Debugger > Automatic Completions and in the Suggestions and completions section, clear the
Use tab to show suggestions (in addition to ctrl+space) option. If there are no available
completions, MATLAB always inserts a tab.
In the Command Window, to insert a tab, you must disable showing name suggestions on tab. To
disable showing name suggestions, in the Preferences window, select MATLAB > Command
Window > Automatic Completions and clear the Enable tab completion option. In the MATLAB
Online Command Window, clear the Use tab to show suggestions (in addition to ctrl+space)
option.
3-22
Check Syntax as You Type
When you type the name of a function followed by an opening parenthesis, MATLAB shows the basic
syntax information for the function. In the Editor, Live Editor, App Designer, and MATLAB Online
Command Window, if a function has multiple syntaxes, you can use the drop-down arrow to the right
of the syntax to show all available syntaxes. Alternatively, use Ctrl+Down Arrow to show and hide
the additional syntaxes. On macOS systems, use the Command key instead of Ctrl.
You can type an input for any argument that appears in blue. Enter your own input variables or
values, and not the argument names shown in the suggestion. The displayed syntax options change
based on the arguments you enter.
In the Editor, Live Editor, App Designer, and MATLAB Online Command Window, MATLAB shows
descriptions for each argument. Optional arguments are indicated by the (Optional) keyword next to
the argument description. If MATLAB suggests multiple arguments, click the arrow to the right of the
argument description to view the additional arguments. Alternatively, you can use the Ctrl+Alt
+Right Arrow and Ctrl+Alt+Left Arrow keyboard shortcuts.
To open the documentation for the function MATLAB is showing syntax suggestions for, click the Help
button to the left of the function syntax suggestions, or, in the Command Window, click the More
Help... link below the function syntax suggestions.
Suggestions for function syntaxes and arguments appear for MATLAB installed functions and for
functions that you create. The suggestions for MATLAB functions come from the documentation. The
suggestions for functions that you create come from the function definition statement (first
executable line) in the MATLAB program file. That file must be on the search path or in the current
folder. For more information about adding help to the functions that you create, see “Add Help for
Your Program” and “Customize Code Suggestions and Completions”.
In the Editor, Live Editor, and App Designer, you can disable showing suggestions automatically. You
also can disable the use of the Tab key for showing suggestions and the use of the Right Arrow key
for accepting suggestions. To disable these options, go to the Home tab, and in the Environment
3-23
3 Entering Commands
section, click Preferences. Select MATLAB > Editor/Debugger > Automatic Completions
and in the Suggestions and completions section, clear one or more of the options:
• To disable showing suggestions automatically, clear the Show suggestions automatically option.
• To disable showing suggestions after you press the Tab key, clear the Use tab to show
suggestions (in addition to ctrl+space) option. When this option is cleared, you can still show
suggestions by pressing Ctrl+Space.
• To disable accepting a suggestion using the Right Arrow key, clear the Use right arrow to
accept suggestions (in addition to tab and enter) option. When this option is cleared, you can
still accept a suggestion using the Tab and Enter keys.
In the Command Window, you can disable showing name suggestions and function syntax
suggestions. To disable showing name suggestions, in the Preferences window, select MATLAB >
Command Window > Automatic Completions and clear the Enable tab completion option. To
disable showing function syntax suggestions, clear the Enable function hints option. To disable
reducing the list of suggestions as you type each additional character and press the Tab key, clear the
Tab key narrows completions option.
In MATLAB Online, the Command Window behavior matches the Editor, Live Editor, and App
Designer behavior. To disable showing suggestions automatically, using the Tab key for showing
suggestions, and using the Right Arrow key for accepting suggestions, in the Preferences window,
select MATLAB > Command Window > Automatic Completions. Then, in the Suggestions and
completions section, clear one or more of the options.
See Also
Related Examples
• “Enter Statements in Command Window” on page 3-2
• “Set Command Window Preferences” on page 3-16
3-24
Set Command History Preferences
You can exclude statements from the command history and specify how many commands to save to
the command history file, History.xml. MATLAB uses the command history file for both the
Command History window and statement recall in the Command Window.
Note When you exclude statements from the command history file, you cannot recall them in the
Command Window, nor can you view them in the Command History window.
You can also change the way you search for previously executed statements in the command history.
Select from different search text matching options and change the way results are displayed in the
Command History window.
To set Command History preferences, on the Home tab, in the Environment section, click
Preferences. Select MATLAB > Command History, and then adjust the options as described in the
following table.
Option Usage
Save Select Save exit/quit commands to save exit and quit
commands in the command history.
Select Save consecutive duplicate commands to save
consecutive executions of the same statement in the command
history.
Any entries predating the current session remain unless you first
delete entries from the Command History window.
Save last n commands specifies the number of commands to save.
Match Select Match anywhere to retrieve statements that contain the
search text in any location.
3-25
3 Entering Commands
Option Usage
Select Filter matches to display only statements that match the
search text. Clear Filter matches to display all previously executed
statements and highlight the statements that match the search text.
Show Select Show match toolbar to display a search toolbar at the top of
the Command History window. Search for previously executed
statements using the search field and change Match preferences
using the provided buttons.
Select Show match locations to display yellow markers to the
right of the scroll bar in the Command History window that indicate
the location of matches throughout the command history.
Select Show execution time to display an approximate execution
time to the right of each statement. Times display for any
statements that take longer than 0.1 seconds to execute.
Favorite Commands Select Don't show to disable showing favorite commands in the
Command History window.
1 Change the short date format for your operating system as described in its documentation.
2 Restart MATLAB.
Note Clearing the command history deletes all entries from the Command History window. You
can no longer recall those entries in the Command Window.
See Also
Command History
3-26
4
Each MATLAB function has supporting documentation that includes examples and describes the
function inputs, outputs, and calling syntax. This table describes ways to access that documentation.
See Also
doc
More About
• “MATLAB Code Examples” on page 4-3
• “Search Syntax and Tips” on page 4-5
4-2
MATLAB Code Examples
To access examples, click Examples at the top of a documentation page. The Help browser displays
the examples for the current product category.
MATLAB includes examples that demonstrate various functionalities. For instance, to view examples
demonstrating plotting in MATLAB, navigate to the MATLAB > Graphics > 2-D and 3-D Plots
category and click Examples at the top of the page.
To copy the example and supporting files onto your system and open the example, use the buttons at
the top of each example:
• When viewing an example in the Help browser — Click the button to open the example in
MATLAB. For instance, if the example is a live script, click the Open Live Script button to open
the example live script in MATLAB.
• When viewing an example in a web browser — Click the Copy Command button to copy the
command that opens the example. Then, enter the copied command into the MATLAB Command
4-3
4 Help and Product Information
Window. You also can open some examples directly in your web browser by clicking the Try This
Example button.
Once the example is open, run it by clicking Run . To run the example one section at a time and
view the incremental results, select the first section and then step through the script by clicking Run
and Advance .
Additional examples, created by members of the MATLAB community, are available at the File
Exchange.
Inline Examples
The product documentation also includes inline code excerpts, such as examples on function pages
like cos or plot. You can run inline code from the Help browser by selecting the code, right-clicking,
and then selecting Evaluate Selection, as shown.
See Also
demo | echodemo | openExample
Related Examples
• “Create and Run Sections in Code”
External Websites
• File Exchange
4-4
Search Syntax and Tips
You can search for keywords in the documentation by entering text in the Search box in the top-right
corner of the desktop or by entering text in the Help browser.
When you open a page from the search results, the keywords that you searched for appear
highlighted. To clear the highlighting, press the Esc key.
• Search for the word instead of the symbol or character, such as plus instead of +.
• View the documentation on “MATLAB Operators and Special Characters”.
• Search the PDF documentation, available from the documentation home page.
Example: "plot tools" finds pages that contain plot tools, in that sequence, with no
words between them.
* Wildcard
Requires at least two nonwildcard characters, and cannot appear at the start of a keyword
or in an exact phrase.
Example: "plot tools" NOT "time series" finds pages with plot tools but excludes
pages with time series.
AND Boolean AND
The Help browser search evaluates NOT operators first, OR operators second, and AND operators last.
4-5
4 Help and Product Information
For example, this text searches for pages that contain either plotting tool or plot tools and contain
workspace, but do not contain time series.
Filter Results
You can filter search results using facets that appear on the left side of the page. For example, view
MATLAB topics by selecting MATLAB and Help Topics.
See Also
docsearch
Related Examples
• “Ways to Get Function Help” on page 4-2
4-6
Bookmark and Share Page Locations
In this section...
“Bookmark Favorite Pages” on page 4-7
“View Page Locations” on page 4-7
When you add a favorite, do not change the Callback. MATLAB requires special values to create a
shortcut that opens the page in the Help browser. In addition, if you want the bookmark to appear in
your list of favorites, keep the Category set to Help Browser Favorites, as shown.
Note You cannot migrate favorites that you save in one MATLAB release to a new release.
To identify the location of a page in the Help browser to share with someone else, right-click within
the page, and then select Get Page Address.
The Help Page Location dialog box provides two ways to access the page:
• A web command to run from the command line that opens the page from the installed
documentation. This command is subject to change between releases, so it is not always accurate
for someone running a different version of MATLAB.
• A URL for the page corresponding to your product version at the MathWorks website. This
documentation is available to anyone, even if they do not have MathWorks products. However, to
access archived documentation from previous releases, as well as translated documentation, you
must sign in with a MathWorks Account.
4-7
4 Help and Product Information
Note If you are running a prerelease version, the URL is invalid because the documentation does
not yet exist on the website.
4-8
Contact Technical Support
To contact technical support directly from MATLAB, follow these steps. This method requires an
internet connection.
1
On the Home tab, in the Resources section, click Request Support.
2 When requested, sign in using your MathWorks Account email address and password. If you do
not have a MathWorks Account, create one.
3 Provide information to help technical support reproduce your issue, such as a description of the
steps you followed or a code excerpt. Optionally, you can attach up to five files to your request,
where each file is no larger than 5 MB.
4-9
4 Help and Product Information
Alternatively, you can request support on the MathWorks Support page. For more information, see
Contact Support.
There are also many resources available on the MathWorks Support page. Some of the resources on
the page include documentation for MathWorks products, MATLAB Answers, and installation help.
See Also
External Websites
• MathWorks Support Page
4-10
Help Preferences
Help Preferences
1 On the Home tab, in the Environment section, click Preferences. Select MATLAB > Help.
2 Adjust the preference options as described in the table.
Preference Usage
Documentation Location Specify whether to view the documentation on the web at https://
www.mathworks.com/help (recommended) or the documentation
installed locally on your system. Viewing the web documentation requires
an internet connection.
If the Help browser is already open, changes to this preference apply only
to new Help browser tabs.
Selected Products Select the products to include for viewing and searching documentation
in the Help browser or Function Browser.
If the Help browser is already open, changes to this preference apply only
to new Help browser tabs.
Quick Help Display Specify whether help links display content in the Help browser or in a
small window. This preference applies to reference pages or program
help that you access using:
This option is available for selected non-English systems only. For more
information, see “Translated Documentation” on page 4-13.
To adjust the font size in the Help browser, use the Ctrl+Plus (+) and Ctrl+Minus (-) keyboard
shortcuts. On macOS systems, use the Command key instead of the Ctrl key.
4-11
4 Help and Product Information
See Also
More About
• “Install Documentation”
• “Translated Documentation” on page 4-13
4-12
Translated Documentation
Translated Documentation
Many MathWorks products have translated documentation in Japanese. In addition, some features of
MATLAB have translated documentation in Korean, simplified Chinese, Spanish, French, Italian, and
German. If you install documentation locally, a product with translated documentation usually installs
the translated documentation from the previous version and the English documentation for the
current version.
For information about documentation in other languages, contact your MathWorks Sales and Service
office.
Note The Language preference appears only when your system language is set to Japanese,
Korean, Chinese, Spanish, French, Italian, or German.
The Language preference changes the language only in the Help browser and context-sensitive help.
To change the language of the text in the MATLAB desktop, see “Change the MATLAB Desktop
Language” on page 9-14.
If the locale setting for your system (or display language on Windows 10) is set to Japanese, Korean,
or Chinese, you also can choose whether to view the installed documentation in your system language
or in English. Documentation in Spanish, French, Italian, and German is available only on the web.
4-13
4 Help and Product Information
2 Click the country selection button at the bottom of the webpage, and select a country based on
the language in which you want to view the documentation.
See Also
Related Examples
• “Change the MATLAB Desktop Language” on page 9-14
• “Help Preferences” on page 4-11
• “Set Locale on Microsoft Windows Platforms” on page 9-5
• “Set Locale on Linux Platforms” on page 9-8
• “Set Locale on macOS Platforms” on page 9-7
4-14
Information About Your Installation
4-15
4 Help and Product Information
Install Documentation
By default, when using MATLAB, you access product documentation on the web. This reduces the
installation footprint.
To use documentation when your computer is not connected to the internet—either temporarily or
permanently — you can install the documentation on your machine.
To install the documentation, on a computer connected to the internet, follow the procedure in
“Install Documentation”.
4-16
5
Create Variables
The MATLAB workspace consists of the variables you create and store in memory during a MATLAB
session. You can create new variables in the workspace by running MATLAB code or using existing
variables.
To create a new variable, enter the variable name in the Command Window, followed by an equal sign
(=) and the value you want to assign to the variable. For example, if you run these statements,
MATLAB adds the four variables x, A, I, and C to the workspace:
x = 5.71;
A = [1 2 3; 4 5 6; 7 8 9];
I = besseli(x,A);
C = {A A A};
If you do not end the assignment statement with a semicolon (;), MATLAB displays the result in the
Command Window. For example,
x = 5.71
x =
5.7100
If you do not explicitly assign the output of a statement to a variable, MATLAB generally assigns the
result to the reserved word ans. The value of ans changes with every statement that returns an
output value that is not assigned to a variable. For example,
sin(1)
ans =
0.8415
To view and edit variables, use the Workspace browser and Variables editor. (Some editing options
are not available in MATLAB Online.)
5-2
Create and Edit Variables
To open the Workspace browser if it is not currently visible, do either of the following:
• On the Home tab, in the Environment section, click Layout. Then, under Show, select
Workspace.
• Type workspace in the Command Window.
By default, the Workspace browser displays the base workspace. You also can view function
workspaces if MATLAB is in debug mode. For more information, see “Base and Function
Workspaces”.
To display additional columns such as size and range, on the Workspace browser title bar, click the
Show Workspace Actions button , and then click Choose Columns. In MATLAB Online, to select
which columns to display, right-click a column name in the Workspace panel and select or clear the
desired column names.
You also can use the who command in the Command Window to view a list of variables. To list
information about size and class, use the whos command. For example, if you have the variables x, A,
and I in your workspace, you can run the who and whos commands to view your workspace contents:
who
A C I x
whos
A 3x3 72 double
C 1x3 528 cell
I 3x3 72 double
x 1x1 8 double
• Command Window — Type the variable name at the command prompt. For example:
x =
5.7100
• Variables editor — In the Workspace browser, double-click a variable name. The Variables editor
opens for that variable.
5-3
5 Workspace Browser and Variable Editor
Some variables open a viewer or other tool appropriate for their type. For details, see the
documentation for that data or object type.
To change how the Variables editor displays variables, go to the View tab, and in the Format
section, select a number display format. The display format does not affect how values are
displayed in the Command Window or Workspace browser, or how the variables are saved.
Note The maximum number of elements in a variable that you can open in the Variables editor
depends on your operating system and the amount of physical memory installed on your system.
To edit other variables, open them in the Variables editor. For example, suppose that you create a cell
array, C, by running these commands in the Command Window:
A = magic(4);
C = {A A A};
In the Workspace browser, double-click the variable name C to open it in the Variables editor.
5-4
Create and Edit Variables
To edit an element of a variable, double-click the element. The element opens in a new document
within the Variables editor. For example, if you double-click element C{1,1} in the Variables editor,
the contents of that cell open in a new tab. You can edit the value of a variable element by clicking
the element and typing a new value. Press Enter or click another element to save the change.
To return to the parent cell array or structure of an element, go to the View tab and click the Go Up
button.
Changes you make in the Variables editor are automatically saved in the workspace. Changes you
make to variables via the Command Window or other operations automatically update the information
for those variables in the Workspace browser and Variables editor.
Note
• You cannot edit elements or subsets of multidimensional arrays in the Variables editor.
• You cannot edit tall arrays in the Variables editor.
• When editing strings in the Workspace browser or as part of a structure in the Variables editor,
you must use double quotes to surround the string value.
Tables (including timetables) and structure arrays support additional editing actions.
5-5
5 Workspace Browser and Variable Editor
Action Procedure
Modify column or row name Double-click the name and enter the new text.
Reorder variables Hover over the left side of a variable until a four-headed arrow
appears. Then, click and drag the column to a new location.
Modify units and description of Click the arrow that appears to the right of a variable name. Then,
variables enter new text in the Units and Description fields.
5-6
Create and Edit Variables
Action Procedure
Sort variable data Click the arrow that appears to the right of a variable name and
select Ascending or Descending.
Note The contents of a table are only visible and modifiable when the number of variables is fewer
than 5000. When the number of variables equals or exceeds 5000, you can only view the table
properties.
Changes made to certain variable types in the Variables editor also appear in the Command Window.
For example, suppose you have a table T that contains three columns, A, B, and C. If you delete
column A in the Variables editor, the line T(:,'A') = []; displays in the Command Window. To
suppress code display in the Command Window, on the View tab, clear the Show MATLAB Code
check box.
Action Procedure
Delete row, column, or variable Right-click the desired row header, column header, or selected
elements elements and select Delete Row or Delete Column.
Insert new row or column Right-click the desired row header, column header, or element and
select Insert Row Above, Insert Row Below, Insert Column to
the Left, or Insert Column to the Right. You can also add rows
or columns simply by entering a value in an empty row or column.
For example, to add a row and column to the array in C{1,1},
enter a value in element (5,5).
5-7
5 Workspace Browser and Variable Editor
Action Procedure
Cut variable elements Right-click the desired row header, column header, or selected
elements and select Cut. The cut values move to the clipboard and
are replaced by the default value for empty elements. For more
information, see “Empty Elements” on page 5-8.
Copy variable elements Right-click the desired row header, column header, or selected
elements and select Copy.
Paste variable elements Right-click the row header, column header, or element where you
want the insertion to begin and select Paste.
Paste cells from Microsoft Excel Right-click the element where you want the insertion to begin, and
spreadsheet then select Paste Excel Data.
Empty Elements
Empty elements in variables are assigned default values. Default assignments are:
Action Procedure
Copy variable to and from Select the variables, right-click, and then select Copy. Then, you
clipboard can paste the names, for example, into the Command Window or
an external application. Multiple variables are comma-separated.
Duplicate variable Select the variables, right-click, and then select Duplicate.
MATLAB creates a copy of the selected variables.
Rename a workspace variable Right-click the variable name, and then select Rename. Type the
new variable name and press Enter.
Delete all variables in On the Home tab, in the Variable section, click Clear
workspace Workspace.
You also can use the clear function in the Command Window.
Delete selected variables from Select the variables in the Workspace browser, right-click, and
workspace then select Delete.
You can also use the clear function in the Command Window. For
example, to clear variables A and B, use the command clear A B.
5-8
Create and Edit Variables
To create a new workspace variable from an existing variable, in the Variables editor, select an
element, data range, row, or column in an array, and then in the Variable tab, select New from
Selection.
You can change the character that delimits decimals in the data when you cut and paste values from
the Variables editor into text files or other applications. You might do this, for instance, if you provide
data to a locale that uses a character other than the period (.). To change the delimiter character,
specify a Decimal separator for exporting numeric data via system clipboard in the “Variables
Preferences” on page 5-15.
Within a selection, Tab also moves from the last column in one row
to the first column in the next row.
Move in opposite direction of Enter or Tab. Shift+Enter or Shift+Tab
Move up m rows, where m is the number of visible rows. Page Up
Move down m rows, where m is the number of visible rows. Page Down
Move to column 1. Home
Move to row 1, column 1. Ctrl+Home
Edit current element, positioning cursor at the end of the element. F2 (Ctrl+U on Apple Macintosh
platforms)
See Also
openvar | Workspace Browser
More About
• “Variable Names”
• “Display Statistics in the Workspace Browser” on page 5-10
• “Workspace and Variable Preferences” on page 5-14
• “Save and Load Workspace Variables” on page 5-12
5-9
5 Workspace Browser and Variable Editor
To display statistics, on the Workspace browser title bar, click the Show Workspace Actions
button, and then select Choose Columns. Select the statistics you want MATLAB to calculate. In
MATLAB Online, to select which columns to display, right-click a column name in the Workspace
panel and select or clear the desired column names.
On the Workspace browser title bar, click the Show Workspace Actions button, and then
select Choose Columns. Clear the statistics that you do not want MATLAB to calculate. In
MATLAB Online, to change which statistics display, right-click a column name in the Workspace
panel and clear the statistics that you do not want MATLAB to calculate.
• Exclude large arrays from statistical calculations.
On the Home tab, in the Environment section, click the Specify preferences button. Select
MATLAB > Workspace, and then use the arrow buttons under Statistical calculations to
change the maximum array size for which the Workspace browser performs statistical
calculations. Any variable exceeding the maximum array size reports <Too many elements> in
Workspace browser statistics columns instead of statistical results.
If a variable includes a NaN, and you select this option, the values for Min, Max, Var, and several
other statistics appear as NaN. However, Mode and several other statistics show a numeric result.
• Ignore NaNs whenever possible
If a variable includes a NaN, and you select this option, numeric results appear for most statistics
including Min, Max, and Mode. However, Var still appears as NaN.
5-10
Display Statistics in the Workspace Browser
See Also
More About
• “Infinity and NaN”
• “Workspace and Variable Preferences” on page 5-14
5-11
5 Workspace Browser and Variable Editor
The workspace is not maintained across sessions of MATLAB. When you quit MATLAB, the workspace
clears. However, you can save any or all the variables in the current workspace to a MAT-file (.mat).
You can then reuse the workspace variables later during the current MATLAB session or during
another session by loading the saved MAT-file.
• To save all workspace variables to a MAT-file, on the Home tab, in the Variable section, click
Save Workspace.
• To save a subset of your workspace variables to a MAT-file, select the variables in the Workspace
browser, right-click, and then select Save As. You also can drag the selected variables from the
Workspace browser to the Current Folder browser.
• To save variables to a MATLAB script, click the Save Workspace button or select the Save As
option, and in the Save As window, set the Save as type option to MATLAB Script. Variables
that cannot be saved to a script are saved to a MAT-file with the same name as that of the script.
You also can save workspace variables programmatically using the save function. For example, to
save all current workspace variables to the file june10.mat, use the command
save('june10')
To save only variables A and B to the file june10.mat, use the command
save('june10','A','B')
To store fields of a scalar structure as individual variables, use the save function with the -struct
option. This can be useful if you previously loaded variables from a MAT-File into a structure using
the syntax S = load(filename) and want to keep the original variable structure when saving to a
new MAT-File.
To save part of a variable, use the matfile function. This can be useful if you are working with very
large data sets that are otherwise too large to fit in memory. For more information, see “Save and
Load Parts of Variables in MAT-Files”.
In MATLAB Online, variables persist between sessions. Saving allows you to clear the workspace and
load variables at a later time. To save variables, use the save or matfile functions.
To load a subset of variables from a MAT-file on the Home tab, in the Variable section, click Import
Data. Select the MAT-file you want to load and click Open. You also can drag the desired variables
from the Current Folder browser Details panel of the selected MAT-file to the Workspace browser. In
MATLAB Online, you also can click the Preview button to the right of the MAT-file in the Files
browser and drag the desired variables from the preview to the Workspace panel.
5-12
Save and Load Workspace Variables
To load variables saved to a MATLAB script into the workspace, simply run the script.
You also can load saved variables programmatically, use the load function. For example, load all
variables from the file durer.mat
load('durer')
load('durer','X','map')
To load part of a variable, use the matfile function. This is useful if you are working with very large
data sets that are otherwise too large to fit in memory. For more information, see “Save and Load
Parts of Variables in MAT-Files”.
Caution When you load data into the MATLAB workspace, the new variables you create overwrite
any existing variables in the workspace that have the same name. To avoid overwriting existing
variables, use the load function to load the variables into a structure. For example, S =
load('durer') loads all the variables from the file durer.mat into the structure S.
Alternatively, use the command whos -file filename. This function returns the name, dimensions,
size, and class of all variables in the specified MAT-file. For example, you can view the contents of the
example file durer.mat.
The byte counts represent the number of bytes that the data occupies in memory when loaded into
the MATLAB workspace. Because of compression, data encoding, and metadata, the space occupied
in the file by a variable may be different from the in-memory size. MATLAB compresses data in
Version 7 or higher MAT-files. For more information, see “MAT-File Versions”.
See Also
save | load
More About
• “MAT-File Versions”
• “Save and Load Parts of Variables in MAT-Files”
5-13
5 Workspace Browser and Variable Editor
In this section...
“Workspace Preferences” on page 5-14
“Variables Preferences” on page 5-15
Workspace Preferences
Workspace preferences enable you to configure options for saving workspace variables to MATLAB
scripts. They also enable you to restrict the size of arrays on which MATLAB performs calculations,
and to specify if you want those calculations to include or ignore NaNs.
To open Workspace preferences, on the Home tab, in the Environment section, click
Preferences. Select MATLAB > Workspace.
Preference Usage
Threshold for saving variables to MATLAB Specify Maximum array size to limit the
script number of elements of arrays saved to a MATLAB
script.
Specify Maximum struct/object nesting levels
to limit the nesting level of structures, arrays, or
objects saved to a MATLAB script.
Multidimensional array formatting Specify how multidimensional arrays are
formatted when saved to a MATLAB script.
5-14
Workspace and Variable Preferences
Preference Usage
Specify whether NaN values are included or
excluded from calculations for the statistics
displayed in the Workspace browser.
Variables Preferences
When working in the Variables editor, Variables preferences enable you to specify array formatting,
cursor movement, and the decimal separator for exporting data using the system clipboard.
To open Variables preferences, on the Home tab, in the Environment section, click Preferences.
Select MATLAB > Variables.
Preference Usage
Format Select an option from the Default array format to specify the
default array output format of numeric values displayed in the
Variables editor. This format preference affects only how numbers
display, not how MATLAB computes or saves them. For
information on formatting options, see the reference page for the
format function.
5-15
5 Workspace Browser and Variable Editor
Preference Usage
Editing Specify where the cursor moves to after you type an element and
press Enter.
To keep the cursor in the element where you typed, clear the
Move selection after Enter check box.
Some Variables preferences are not available in MATLAB Online. To show generated code in the
Command Window when performing operations in the MATLAB Online Variables Editor, select Show
MATLAB code for operations.
See Also
More About
• “Create and Edit Variables” on page 5-2
5-16
6
Find Files
In this section...
“Simple Search for File Names” on page 6-2
“Advanced Search for Files” on page 6-2
“Advanced Search in MATLAB Online” on page 6-4
1
Click the search button in the current folder toolbar. The address bar becomes a search field.
2 Type a portion of a file name. The asterisk character (*) is a wildcard. For example, to show only
file names that begin with coll and have a .m extension, type coll*.m.
3 Press Enter.
MATLAB displays all files within the current folder (including its subfolders) that match that file
name. If you typed the full path to a folder, that folder becomes the current folder.
To clear the results and show all items in the current folder, press the Esc key.
In MATLAB Online, to search for files in the current folder or in the current project, go to the Home
To perform an advanced search for files, you can use the Find Files tool. Use the Find Files tool to:
To open the Find Files tool, on the Home tab, in the File section, click Find Files. Enter your
search criteria in the dialog box that opens.
6-2
Find Files
Use the Look in menu to specify the folders you want to search. Select Entire MATLAB Path to
search all folders on the MATLAB search path. Alternatively, you can browse for a folder by selecting
Browse... or you can enter the full path for one or more folders. Separate each path with a semicolon
(;).
Click Find to begin the search. Search results appear in the right pane of the dialog box, with a
summary at the bottom. For text searches, results include the line number and line of code. To see file
locations, select Show full path names.
Open one or more files by right-clicking the files and selecting one of the Open options.
You can search for files with only a specified extension, by selecting an option in the Include only
file type(s) menu. For example, select *.m, *.mlx to limit the search to MATLAB program files.
1 In the Include only file type(s) menu, select All files (*).
2 Under More options, select the Skip file type(s) box and click Edit. The Edit Skipped File
Extensions dialog box opens.
3 Select the State check box for the file types to exclude from your search.
4 Click OK to accept your changes.
You can remove any file extension from the list by selecting the extension to highlight it. Then, click
Remove.
Under More options, you can choose to search file contents for a partial word. From the Search
type menu, select Contains text. To find an exact full-word match, select Matches whole word.
6-3
6 Managing Files in MATLAB
Searching within large files can be time consuming. To speed up your search, specify a file size in the
Skip files over field. The Find Files tool ignores files larger than the size you specify.
Troubleshooting
If the Find Files tool does not find the file you want, try the following:
• When searching for file names, use the asterisk character (*) as a wildcard character to expand
your search. For example, to show file names that begin with coll and have a .m extension, type
coll*.m.
• Select the Include Subfolders check box if the file might be in a subfolder.
• If you select the Skip file type(s) check box, ensure that you do not exclude relevant file types
from your search. Click Edit and review the Edit Skipped File Extensions dialog box. Ensure that
relevant file types do not have the State check box selected.
In MATLAB Online, to perform an advanced search for files, click the Find Files icon in the
sidebar. If the Find Files icon is not in the left or right sidebar, go to the Home tab, and in the File
section, click Find Files.
Select a search option to change how the Find Files tool searches for text:
• Match case – Search only for text with the precise case of the search text.
• Match whole word – Search only for exact full-word matches.
You also can use the Filters button to specify whether to search for file names or file content, what
folder to search in, and what file types to include in the results.
See Also
dir | exist | what | which
More About
• “Find Functions to Use” on page 3-4
6-4
Find Files
6-5
6 Managing Files in MATLAB
You can use the Comparison Tool to display the differences between selected pairs of files or folders.
For some file types, you also can merge changes from one file to the other.
Comparison Process
The comparison process involves three steps:
1 Select the files or folders to compare.
2 Choose a comparison type.
3 Explore the comparison report.
You can select files and folders to compare using any of these methods:
•
MATLAB desktop — Go to the Home tab, and in the File section, click Compare. Click the
button to select items to compare, or drag and drop files from your file browser into the First file
or folder or Second file or folder fields.
• Current Folder browser — Select a file or folder, right-click, and select Compare Against. Click
the button to select a second item to compare, or drag and drop a file from your file browser
into the Second file or folder field. To select two files or subfolders to compare, Ctrl-click the file
names. Then right-click and select Compare Selected Files/Folders.
• Editor or Live Editor — Go to the Editor or Live Editor tab, and in the File section, click
Compare. The Comparison Tool includes the currently open file in the First file or folder field.
Click the button to select a second item to compare, or drag and drop a file from your file
browser into the Second file or folder field.
To compare a file with the autosave version or the saved version on disk, go to the Editor tab and
click Compare and select Compare with Version on Disk or Save and Compare with
Autosave. If your file is modified, the Editor saves the file before comparing. The Compare with
Version on Disk and Save and Compare with Autosave options are only available if the option
for automatically saving changes to a file is disabled. To disable the option, go to the Home tab,
and in the Environment section, click Preferences. Then, select Editor/Debugger and clear
Save changes upon clicking away from a file. This option is not available in the Live Editor.
• Command Window — Use the visdiff function. For example, to compare the two files
lengthofline.m and lengthofline2.m using the visdiff function and the default text
comparison, type visdiff('lengthofline.m','lengthofline2.m'). MATLAB opens the
Comparison Tool and displays the resulting comparison report.
Tip When selecting folders to compare, select Include subfolders to include subfolder content in
the comparison.
The Comparison Tool compares selected items using the default comparison type defined for the
selected items. For some item types, you can select a different comparison type from the default. For
6-6
Compare Files and Folders and Merge Files
example, you can choose from a text, binary, file list, or XML comparison. To change the comparison
type, select the files or folders to compare. Then, select from the available Comparison type options.
The Comparison Tool displays only the valid options for the selected item types.
You cannot change the comparison type for an existing comparison report. To change the comparison
type, start a new comparison.
If you specify two files or folders to compare using either the Current Folder browser or the visdiff
function, then the Comparison Tool automatically performs the default comparison type. For example,
from the Current Folder browser, if you select two XML files to compare, the tool uses the default text
comparison. To change the comparison type to a hierarchical comparison instead, create a new
comparison using the Comparison Tool.
After selecting the comparison type, click the Compare button. The comparison report opens. You
can explore the comparison report in different ways depending on the items being compared. For
more information, see the details described for each comparison type below.
You can compare any combination of folders and ZIP files using the Comparison Tool. For example,
you can compare the contents of a folder to the contents of a ZIP file. The Comparison Tool performs
a file list comparison of the selected items.
When you perform a file list comparison, a new window opens and displays the contents of the
specified lists side by side. For example, suppose that you have two folders, curvefittings and
curvefittings2, with several differences. When you compare the two folders, the Comparison Tool
displays the resulting report.
6-7
6 Managing Files in MATLAB
The Comparison Tool highlights files and subfolders that do not match using the colors listed in this
table.
• To sort the results by name, type, size, or last modified timestamp, click the corresponding column
header. For example, click the Type column header to sort by folder and file type.
• To open a detailed comparison report for items with differing content, click the compare link next
to the item.
• To open a file in the Editor, click the open link next to a file name. If the file is present in both
folders, you can click links to open the left or right version of the file.
• If subfolders are very large and contain many files, analysis continues in the background. The tool
displays the number of items still to be compared at the top of the report. You can click Skip
Current to skip the current item or Cancel All to stop further analysis.
6-8
Compare Files and Folders and Merge Files
• To save time when reviewing differences, especially when comparing many subfolders, you can
filter the report. To apply a filter, on the View tab, select Filter > "filterName".
To create a new filter, on the View tab, select Filter > Add/Remove Filter. You can specify filters
to ignore certain files and folders, such as backup files or files created by a revision control
system. For example, to ignore all files and folders in a folder named CVS, type CVS/. To ignore all
files in a folder named CVS, but not ignore subfolders, type CVS/*.
For information about how to further configure the comparison report, see “Additional Comparison
Tools” on page 6-15.
In MATLAB Online, you can compare project definition files. When you compare folders, MATLAB
detects whether they are project root folders. MATLAB looks for and compares the project definition
files stored in the resources or .SimulinkProject folder. Project definition files contain
information about the project path, project settings, shortcuts, labels, and referenced projects.
To compare project definition files, select the PRJ files or the project root folders, right-click your
selection and select Compare Selected Files/Folders. When you select a node in the results report,
the Comparison Tool shows more details in the bottom pane.
6-9
6 Managing Files in MATLAB
6-10
Compare Files and Folders and Merge Files
Compare Files
A user made some changes to lengthofline.m and saved the resulting file as lengthofline2.m.
visdiff("lengthofline.m","lengthofline2.m")
6-11
6 Managing Files in MATLAB
The Comparison Tool displays the total number of differences in the bottom-right corner of the
comparison report and highlights the lines that have changed with the colors listed in this table.
6-12
Compare Files and Folders and Merge Files
The Comparison Tool attempts to match lines and detects text that is added, deleted, or changed. For
example, in the text comparison of lengthofline.m and lengthofline2.m, the tool determines
that lengthofline2.m has a line of code that does not exist in lengthofline.m and highlights it
(line 22) in blue. Also, the tool takes the additional line into account and determines that the line
containing the end statement in each file matches, even though the end statement does not occur on
the same line number in both files.
You further can explore and configure the results using several methods:
• Ignore white space differences — To help distinguish between functional changes and changes to
indentation, you can hide white space differences. To hide differences that only involve white
space characters, click Filter, and select Ignore White Space.
•
Show compared files details — To show the file details, click the expand arrow next to the file
name.
• Save comparison report — To save a copy of the comparison report, select Publish > Publish to
HTML, Publish to Word, or Publish to PDF.
For information about how to further configure the comparison report, see “Additional Comparison
Tools” on page 6-15.
To step through the results one difference at a time, use the Next and Previous buttons.
By default, XML files are compared using a text comparison. To compare XML files with a
hierarchical comparison instead, see “Compare XML Files” on page 6-29.
To begin merging, on the Comparison tab, click the Merge Mode button. Then, to replace
content from the right pane with content from the left pane, click the button located next to the
line you want to merge. You also can select a difference and, in the Comparison tab, click the
Replace Content button.
The right pane contains the merged result. An asterisk next to the merged file name in the right pane
(lengthofline2.m *) indicates that the file contains unsaved changes.
To undo a replacement, click the button between the modified lines or on the Comparison tab. To
revert all merges and start again, click the Refresh button. You also can click the Refresh
6-13
6 Managing Files in MATLAB
button to update the comparison report after making changes to and saving the files. Refreshing
discards all unsaved merged changes.
To save your changes and return to the comparison report, click the Save Result button. To
return to the comparison report without saving changes, click the Return to Comparison
button.
You can compare two binary files, such as DLL files or MEX files, using the Comparison Tool. You also
can perform a binary comparison on any two selected files, instead of the default comparison.
To compare any two files using a binary comparison, in the Comparison type menu, select Binary
comparison. When you perform a binary comparison, a new window opens and indicates whether
6-14
Compare Files and Folders and Merge Files
the two files are identical or different. If the files are different, click the Show Details link to view
the binary files and the byte offset of the first difference.
• Live Code — Compare and merge the code and text in two live code files. For more information,
see “Compare and Merge Live Scripts and Functions” on page 6-17.
• Apps — Compare and merge the code in two apps. For more information, see “Compare and
Merge Apps” on page 6-21.
• MAT-Files — Compare and merge variables in two MAT-files. For more information, see “Compare
and Merge MAT-Files” on page 6-25.
• XML Files — Compare two XML files using a text comparison or a hierarchical XML comparison.
For more information, see “Compare XML Files” on page 6-29.
• Simulink Models — If you have Simulink, you can compare and merge Simulink models. For
information, see “Model Comparison” (Simulink).
• Swap Sides button — Switch the left side file or folder with the right side file or folder.
• Refresh button — Update the results in the Comparison Tool after making changes to and saving
the files in the Editor.
• Find button — Find a phrase in the current display. For more information, see “Find Text in
Command Window or History” on page 3-11.
Comparison Preferences
You can customize the Comparison Tool using Comparison preferences. To change the Comparison
preferences, on the Home tab, in the Environment section, click Preferences. Then, select
MATLAB > Comparison.
Color Preferences
You can change the colors that the Comparison Tool uses to highlight lines that have changed. Color
preferences apply to all comparison types.
To change the color preferences, in the Comparison preferences Colors section, change the colors for
differences, modified lines, modified content, and merged lines. The Sample area shows a preview of
the selected colors. After changing comparison colors, you must refresh any open comparison reports
to see the updated colors.
To save the modified color preferences for use in future MATLAB sessions, click Save As and enter a
name for your color settings profile. After saving a color profile, you can select the profile in the
Active Settings list. To restore the default color profile, click Reset.
6-15
6 Managing Files in MATLAB
You can use the Comparison Tool to compare and merge files and folders in external source control
tools. To enable external source control tools to reuse open MATLAB sessions, in the Comparison
preferences External Source Control Integration section, select the Allow external source
control tools to use open MATLAB sessions for diffs and merges option. When you configure
your source control tool to use the MATLAB Comparison Tool, the Comparison Tool prompts you to
select this option.
For more information, see “Customize External Source Control to Use MATLAB for Diff and Merge”
(Simulink).
See Also
visdiff
Related Examples
• “Customize External Source Control to Use MATLAB for Diff and Merge”
External Websites
• Programming: Structuring Code (MathWorks Teaching Resources)
6-16
Compare and Merge Live Scripts and Functions
You can compare two live code files and merge changes between one file and another using the
Comparison Tool. The Comparison Tool highlights differences in code, text, and text formatting.
• Live Editor — Go to the Live Editor tab and, in the File section, click Compare. The Comparison
Tool includes the currently open file in the First file or folder field. Click the button to select
a second item to compare, or drag and drop a file from your file browser into the Second file or
folder field.
•
Current Folder browser — Select a file, right-click, and select Compare Against. Click the
button to select a second item to compare, or drag and drop a file from your file browser into the
Second file or folder field. To select two files or subfolders to compare, Ctrl-click the file names.
Then right-click and select Compare Selected Files/Folders.
• Command Window — Use the visdiff function. For example, to compare the two files
averageweight.mlx and averageweight2.mlx using the visdiff function and the default
text comparison, type visdiff('averageweight.mlx','averageweight2.mlx'). MATLAB
opens the Comparison Tool and displays the resulting comparison report.
Explore Differences
When you perform a live code comparison, a new window opens and displays the two files side by
side. For example, suppose that you have two files, averageweight.mlx and
averageweight2.mlx, with several differences. When you compare the two files, the Comparison
Tool displays the resulting report.
6-17
6 Managing Files in MATLAB
When comparing live code files, the Comparison Tool highlights differences in code, text, and text
formatting. The Comparison Tool ignores output, even if the file contains saved output. If the tool
detects a difference within an equation, image, or control, the entire item is highlighted. The
Comparison Tool displays the total number of differences in the bottom-right corner of the
comparison report, and highlights the lines that do not match using the colors listed in this table.
6-18
Compare and Merge Live Scripts and Functions
The Comparison Tool attempts to match lines and detects code and text that is added, deleted, or
changed. For example, in the live code comparison of averageweight.mlx and
averageweight2.mlx, the tool determines that averageweight.mlx has two lines of code that do
not exist in averageweight2.mlx and highlights them (line 5 and line 7) in yellow. Also, the tool
takes the additional lines into account and determines that the line containing the disp statement in
each file matches, even though the disp statement does not occur on the same line number.
To step through the results one difference at a time, use the Previous and Next buttons.
For information about how to configure the comparison report, see “Compare Files and Folders and
Merge Files” on page 6-6.
Merge Changes
When comparing live code files, you can merge changes from one file to the other. Merging changes
can be useful when resolving conflicts between different versions of files. You only can merge from
left to right. If you want to merge into the left file, click the Swap Sides button before you start
merging. Clicking the Swap Sides button reverts any merges already made and creates a new
comparison report for the original files.
To begin merging, on the Comparison tab, click the Merge Mode button. Then, to replace
content from the right pane with content from the left pane, click the button located next to the
line you want to merge. You also can select a difference and, in the Comparison tab, click the
Replace Content button.
The right pane contains the merged result. An asterisk next to the merged file name in the right pane
(averageweight2.mlx *) indicates that the file contains unsaved changes.
6-19
6 Managing Files in MATLAB
To undo a replacement, click the button between the modified lines or on the Comparison tab. To
revert all merges and start again, click the Refresh button. You also can click the Refresh
button to update the comparison report after making changes to and saving the files in the Live
Editor. Refreshing discards all unsaved merged changes.
To save your changes and return to the comparison report, click the Save Result button. To
return to the comparison report without saving changes, click the Return to Comparison
button.
See Also
visdiff
More About
• “Compare Files and Folders and Merge Files” on page 6-6
• “Customize External Source Control to Use MATLAB for Diff and Merge”
6-20
Compare and Merge Apps
• App Designer — Go to the Designer or Editor tab and, in the File section, click Compare. The
Comparison Tool includes the currently open file in the First file or folder field. Click the
button to select a second item to compare, or drag and drop a file from your file browser into the
Second file or folder field.
•
Current Folder browser — Select a file, right-click, and select Compare Against. Click the
button to select a second item to compare, or drag and drop a file from your file browser into the
Second file or folder field. To select two files or subfolders to compare, Ctrl-click the file names.
Then right-click and select Compare Selected Files/Folders.
• Command Window — Use the visdiff function. For example, to compare the two files
ExplorerE.mlapp and ExplorerF.mlapp using the visdiff function and the default text
comparison, type visdiff('ExplorerE.mlapp','ExplorerF.mlapp'). MATLAB opens the
Comparison Tool and displays the resulting comparison report.
Explore Differences
When you perform an app comparison, a new window opens and displays the two files side by side.
For example, suppose that you have two files ExplorerE.mlapp and ExplorerF.mlapp with
several differences. When you compare the two files, the Comparison Tool displays the resulting
report.
6-21
6 Managing Files in MATLAB
When comparing apps, the Comparison Tool attempts to match lines and detects code that is added,
deleted, or changed. The Comparison Tool displays the total number of differences in the bottom-right
corner of the comparison report and highlights the lines that do not match using the colors listed in
this table.
To step through the results one difference at a time, use the Next and Previous buttons.
6-22
Compare and Merge Apps
For information about how to configure the comparison report, see “Compare Files and Folders and
Merge Files” on page 6-6.
Merge Changes
When comparing apps, you can merge changes from one app to the other. Merging changes can be
useful when resolving conflicts between different versions of an app.
To begin merging, on the Comparison tab, click the Merge Mode button. Then, to replace
content from the right pane with content from the left pane, click the button located next to the
line you want to merge. You also can select a difference and, in the Comparison tab, click the
Replace Content button.
The right pane contains the merged result. An asterisk next to the merged file name in the right pane
(ExplorerF.mlapp*) indicates that the file contains unsaved changes.
To undo a replacement, click the button between the modified lines or on the Comparison tab. To
revert all merges and start again, click the Refresh button. You also can click the Refresh
button to update the comparison report after making changes to and saving the files in the Live
Editor. Refreshing discards all merged changes.
To save your changes and return to the comparison report, click the Save Result button. To
return to the comparison report without saving changes, click the Return to Comparison
button.
6-23
6 Managing Files in MATLAB
You can merge changes only in editable code. Sections of code with a white background are editable.
Examples of editable sections include the body of functions that you define (such as callbacks and
helper functions) and the definitions of custom properties. Sections with a gray background contain
non-editable generated code and therefore cannot be merged. If a change spans both an editable and
a non-editable section, you cannot merge it.
You can merge changes only from left to right. This makes the order of the files in the Comparison
Tool important.
If neither app contains changes in the generated code, place the file containing the changes that you
want to merge in the left pane. You can merge only from left to right. To swap a file from the left pane
to the right pane, click the Swap Sides button before you start merging. Clicking the Swap
Sides button reverts any merges already made and creates a new comparison report for the original
files.
If one of the apps contains changes in the generated code, place the file containing the generated
code that you want in the merged result in the right pane of the Comparison Tool. To swap a file from
the left pane to the right pane, click the Swap Sides button before you start merging.
If both apps contain changes in the generated code, those lines of code cannot be merged in the
Comparison Tool. To merge the files, use App Designer to interactively apply the desired changes to
the app
See Also
visdiff
More About
• “Compare Files and Folders and Merge Files” on page 6-6
• “Customize External Source Control to Use MATLAB for Diff and Merge”
6-24
Compare and Merge MAT-Files
You can use the Comparison Tool to compare two MAT-files. Compare two MAT-files to:
• Determine which variables are common to both files and which appear in only one file.
• Identify differences between individual variables. For example, you can determine which fields of
a structure are different or which elements of an array differ.
• MATLAB desktop — Go to the Home tab and, in the File section, click Compare. Click the
Browse to select File or Folder button to select items to compare, or drag and drop files
from your file browser into the First file or folder or Second file or folder fields.
• Current Folder browser — Select a file, right-click, and select Compare Against > Choose....
Click the Browse to select File or Folder button to select a second item to compare, or drag
and drop a file from your file browser into the Second file or folder field. To select two files or
subfolders to compare, Ctrl-click the file names. Then right-click and select Compare Selected
Files/Folders.
• Command Window — Use the visdiff function. For example, to compare the two files
data1.mat and data2.mat using the visdiff function, type
visdiff('data1.mat','data2.mat'). MATLAB opens the Comparison Tool and displays the
resulting comparison report.
Explore Differences
When you perform a MAT-file comparison, a new window opens and displays the two files side by side.
For example, suppose that you have two MAT-files, data1.mat and data2.mat. When you compare
the two files, the Comparison Tool displays the resulting report.
6-25
6 Managing Files in MATLAB
The Comparison Tool highlights changes in variables. If the variables in both files are equivalent but
the files are not identical, the Comparison Tool displays a message. Possible causes of the differences
between the files include file formats, file timestamps, the order in which the variables are stored, or
variables that contain ignored differences. The Comparison Tool uses these colors to highlight
differences.
Highlighting Description
Purple Values of the variable differ between the two files. Click the compare link
to investigate.
Blue The variable only exists in the right file.
Yellow The variable only exists in the left file.
None The variables in both files are equivalent. The tool ignores differences in
NaN patterns, field ordering in structs, and the difference between
negative zero or positive zero.
Purple (only in Class The variable data class changed. Click the compare link to investigate.
columns)
You can further explore the results in the report using several methods:
6-26
Compare and Merge MAT-Files
• Sort results — To sort the results by name, size, class, or difference summary, click the
corresponding column header. For example, click the Class column header to sort by class type.
• Load variable — To load the contents of a variable into the Variable Editor, click the name of that
variable.
• Load MAT-file — To load one of the MAT-files into the workspace, click the corresponding Load
link at the bottom of the report.
• Save HTML report — To save a copy of the report as an HTML file, go to the Comparison tab and
click Save As > HTML.
For information about how to further configure the comparison report, see “Compare Files and
Folders and Merge Files” on page 6-6.
Compare Variables
To investigate differences between instances of a variable in both files, click the compare link in the
Difference Summary column of the comparison report table. The Comparison Tool displays a report
for the specified variable. To further investigate differences in individual array elements or fields of a
structure, double-click a highlighted row.
Merge Changes
When comparing MAT-files, you can merge changes from one file to the other. There are no undo
capabilities when merging MAT-files, so merge with caution.
To copy modified variables from one file to the other, on the Comparison tab, in the Merge section,
click either the Copy the right variable to the left file or the Copy the left variable to the
right file button, as applicable.
6-27
6 Managing Files in MATLAB
Limitations
In MATLAB Online, the File Comparison Tool does not support variable comparison.
See Also
visdiff
More About
• “Compare Files and Folders and Merge Files” on page 6-6
• “Customize External Source Control to Use MATLAB for Diff and Merge”
6-28
Compare XML Files
In this section...
“Choose XML Files to Compare” on page 6-29
“Change Comparison Type” on page 6-30
“Navigate the XML Comparison Report” on page 6-30
“Save Comparison Log Files in a Zip File” on page 6-31
“Export Results to the Workspace” on page 6-32
You can use the Comparison Tool to compare a pair of XML text files. The tool processes the results
into a report that you can use to explore the file differences. You can compare XML files with a text
comparison or a hierarchical XML comparison.
You can access the XML Comparison Tool from the Current Folder browser, the Comparison Tool, or
programmatically using the visdiff function.
The XML comparison compares the files using the “Chawathe” algorithm, as described in this paper:
Change Detection in Hierarchically Structured Information, Sudarshan Chawathe, Anand Rajaraman,
and Jennifer Widom; SIGMOD Conference, Montreal, Canada, June 1996, pp. 493-504.
XML comparison reports display in the Comparison Tool. For more information about the Comparison
Tool, see “Compare Files and Folders and Merge Files” on page 6-6.
The XML comparison report shows a hierarchical view of the portions of the two XML files that differ.
The report does not show sections of the files that are identical.
If the files are identical, you see a message reporting there are no differences.
Note It might not be possible for the analysis to detect matches between previously corresponding
sections of files that have diverged too much.
Change detection in the Chawathe analysis is based on a scoring algorithm. Items match if their
Chawathe score is above a threshold. The implementation of Chawathe's algorithm uses a comparison
pattern that defines the thresholds.
• For two files in the same folder, select the files, right-click and select Compare Selected Files/
Folders.
• To compare files in different folders:
6-29
6 Managing Files in MATLAB
The XML Comparison Tool performs an analysis on the files and displays a report in the Comparison
Tool. The file you right-click to open the XML Comparison Tool displays on the right side of the report.
For more information about comparisons of other file types with the Comparison Tool, such as text,
MAT, or binary, see “Compare Files and Folders and Merge Files” on page 6-6.
To compare files using the Comparison Tool, from the MATLAB toolstrip, in the File section, select
the Compare button. In the dialog box, select files to compare.
If the files you select to compare are XML files and you select an XML text comparison, the XML
Comparison Tool performs a Chawathe analysis of the XML files, and generates a report.
To change comparison type, either create a new comparison from the Comparison Tool, or use the
Compare Against option from the Current Folder browser. You can change comparison type in the
Select Files or Folders for Comparison dialog box. Select XML text comparison before clicking
Compare.
To step through differences, use the Comparison tab on the toolstrip. To move to the next or
previous group of differences, on the Comparison tab, in the Navigate section, click the arrow
buttons to go to the previous or next difference.
6-30
Compare XML Files
Container None Rows with no highlighting indicate a container item that contains
other modified or unmatched items.
Use the View tab controls on the toolstrip for the following functions:
Tip Right-click to expand or collapse the hierarchy within the selected tree node.
• Collapse All — Collapses all items in the tree to the most compact view possible.
Note It may not be possible for the analysis to detect matches between previously corresponding
sections of files that have diverged too much.
You can zip the temporary files (such as log files) created during XML comparisons, for sharing or
archiving. While the comparison report is open, enter:
xmlcomp.zipTempFiles('c:\work\myexportfolder')
The destination folder must exist. The output reports the zip file name:
6-31
6 Managing Files in MATLAB
To view the log file for the last comparison in the MATLAB Editor, enter:
xmlcomp.showLogFile
1 On the Comparison tab, in the Comparison section, select Save As > Workspace variable.
The xmlcomp.Edits object contains information about the XML comparison including file names,
filters applied, and hierarchical nodes that differ between the two XML files.
To create an xmlcomp.Edits object at the command line without opening the Comparison Tool,
enter:
Edits = xmlcomp.compare(a.xml,b.xml)
6-32
Compare XML Files
See Also
Related Examples
• “Compare Files and Folders and Merge Files” on page 6-6
6-33
6 Managing Files in MATLAB
This table shows how to create, open, move, and rename files and folders on local and network
drives. If you have MATLAB Drive Connector installed on your system, you also can access files and
folders in MATLAB Drive from MATLAB.
6-34
Manage Files and Folders
To open the Current Folder browser if it is not visible, go to the Home tab, and in the Environment
section, click Layout. Then, under Show, select Current Folder. Double-clicking a subfolder
displays its contents, and makes that folder the current folder.
For more information about how to access files in MATLAB Online, see “Access Files in MATLAB
Online” on page 10-2.
See Also
edit | mkdir | open | movefile | rmdir | delete | recycle
6-35
6 Managing Files in MATLAB
More About
• “Save and Back Up Code”
• “Save and Load Workspace Variables” on page 5-12
• “Errors When Updating Folders on Search Path” on page 6-60
• “Access Files in MATLAB Online” on page 10-2
• “Share Folders Using MATLAB Drive” on page 12-11
6-36
Files and Folders that MATLAB Accesses
In this section...
“Where Does MATLAB Look for Files?” on page 6-37
“Files and Folders You Should Add to the Search Path” on page 6-37
“When Multiple Files Have the Same Name” on page 6-37
“Locations of MathWorks Products” on page 6-38
• Change the current folder to the folder that contains the files. Use the cd function or browse to a
different folder in the Current Folder toolbar:
• Add the folder that contains the files to the search path. Changes you make to the search path
apply to the current MATLAB session. To reuse the modified search path in future MATLAB
sessions, save your changes.
• Store individual files in the userpath MATLAB folder, which is on the search path. To determine
the location of this folder, run the userpath function.
For files in @ (class) and + (package) folders, make the parent folder accessible. For details, see
“Folders Containing Class Definitions”.
If files call other files that are in multiple folders, determine the location of all the called files by
performing a dependency analysis on your files. For more information, see “Dependencies Within a
Folder”
6-37
6 Managing Files in MATLAB
Name conflicts arise when MATLAB has access to multiple files with the same name, and when a file
has the same name as a variable in the base workspace or a built-in function for a MathWorks
product.
When there are name conflicts, MATLAB follows these precedence rules:
The file that MATLAB does not use is called a shadowed file. In some cases, MATLAB warns you that a
shadowed file exists.
To see a list of all toolbox folder names supplied with MathWorks products, run:
dir(fullfile(matlabroot,'toolbox'))
See Also
userpath | cd | pwd
More About
• “What Is the MATLAB Search Path?” on page 6-46
• “MATLAB Startup Folder” on page 1-14
• “Toolbox Path Caching in MATLAB” on page 1-21
6-38
Current Folder Browser Preferences
You can specify the number of files that display in the Current Folder browser, and customize their
appearance.
On the Home tab, in the Environment section, click Preferences. Then, select MATLAB >
Current Folder.
Some Current Folder Browser preferences are not available in MATLAB Online.
Preference Usage
History Specify the number of recently used folders maintained in the Current
Folder toolbar drop-down list.
Refresh Specify how frequently the Current Folder browser updates to reflect
changes to files made from programs and tools other than MATLAB.
Select the Indicate inaccessible files check box to dim the display of
files and folders inaccessible to MATLAB. Move the Text and icon
transparency slider to adjust the level of dimming.
Select the Show tooltip explaining why files are inaccessible check
box to display a tooltip that provides information on why a dimmed file
is inaccessible, when you hover over it.
If you do not select the Indicate inaccessible files check box, then the
Current Folder browser displays all files and folders as undimmed and
provides no tooltips.
Toolbar Use the Toolbar preferences to adjust the layout and controls of the
Current Folder toolbar. For more information about how to access
Toolbar preferences, see “Customize MATLAB Toolbars” on page 2-12.
Initial working folder Use the General Preferences options in the Preferences Window to
specify the current folder in MATLAB at startup. For more information
about General Preferences options, see Preferences.
6-39
6 Managing Files in MATLAB
Preference Usage
Hidden Files Specify whether the Current Folder browser displays files and folders
that the operating system hides from system file browsers and file-
listing commands.
To change how dates display in the Current Folder browser, change the short date format for your
operating system. Then, refresh the date display: Right-click in the Current Folder browser and select
Refresh. MATLAB uses your operating system's short date format to display dates in both the
Current Folder browser and the Command History.
See Also
Preferences
More About
• “Manage Files and Folders” on page 6-34
• “Customize MATLAB Toolbars” on page 2-12
6-40
Specify File Names
A path name specifies file locations, for example, C:\work\my_data (on Microsoft Windows
platforms) or /usr/work/my_data (on Linux or Mac platforms). If you do not specify a path name
when accessing a file, MATLAB first searches in the current folder. To indicate a file in a particular
location, specify a path name.
Path name specifications differ, depending on the platform on which you are running MATLAB. Use
the fullfile function to construct path names in statements that work on any platform. This
function is particularly useful when you provide code to someone using it on a platform other than
your own.
fullfile inserts platform-specific file separators where necessary. The file separator character is
the symbol that distinguishes one folder level from another in a path name. A forward slash (/) is a
valid separator on any platform. A backward slash (\) is valid only on Microsoft Windows platforms. In
the full path to a folder, the final slash is optional. Type filesep in the Command Window to
determine the correct file separator character to use on your platform.
To identify the platform on which MATLAB is currently running, use the ismac, ispc, and isunix
functions.
File names must start with a letter, and can contain letters, digits, or underscores.
Avoid using accent characters such as umlauts or circumflexes in path names. MATLAB might not
recognize the path. In addition, attempts to save a file to such a path might result in unpredictable
behavior.
If a path or file name contains spaces, enclose the input in single quotes. For example:
or
MATLAB always accepts absolute path names (also called full path names), such as I:/Documents/
My_Files or /users/myuserid/Homework/myfile.m. An absolute path name can start with any
of the following:
6-41
6 Managing Files in MATLAB
Some MATLAB functions also support relative path names. Unless otherwise noted, the path name is
relative to the current folder. For example:
Tip If multiple documents are open and docked in the Editor, you can copy the absolute path of any
of these documents to the clipboard. This practice is useful if you need to specify the absolute path in
another MATLAB tool or an external application. Right-click the document tab, and then select Copy
Full Path to Clipboard.
A partial path name is the last portion of a full path name for a location on the MATLAB search path.
Some functions accept partial path names.
open database/set
• Locate method files. For example, to check if a plot method exists for the time series object, type:
exist timeseries/plot
Be sure to specify enough of the path name to make the partial path name unique.
The maximum length allowed for a path name depends on your platform.
6-42
Specify File Names
If you get unexpected results when working with long path names, use absolute instead of relative
path names. Alternatively, use shorter names for folders and files.
You call function files by specifying the file name without the file extension. MATLAB returns an error
if it cannot find a case-sensitive match on the search path. By default, MATLAB suggests a function
with the correct case.
When multiple files have the same name, MATLAB follows precedence rules to determine which to
call. For more information, see “Function Precedence Order”.
• When loading or reading from a file, specify the file name using the correct case.
• When saving or writing to a file, MATLAB saves the file in the case you specify. Two files with the
same name, but different cases can exist in the same folder.
Windows platforms — File names are case insensitive. The Windows operating system considers
two files with the same name to be the same file, regardless of case. Therefore, you cannot have two
file names that differ only by case in the same folder.
• When loading or reading from a file, MATLAB accesses the file with the specified name that is
higher on the search path, regardless of case. For example, if you attempt to load MYFILE and
myfile.mat is higher on the search path than MYFILE.MAT, then MATLAB loads myfile.mat
without warning that there is a case mismatch.
• When saving or writing to a file, if you specify a file name that already exists in the folder,
MATLAB accesses the existing file without warning. For example, if you save data to a file named
myfile using the save function, and MYFILE.mat already exists in the folder, the data replaces
the contents of MYFILE.mat. However, the file name remains MYFILE.mat.
See Also
filesep | fullfile | which | ismac | ispc | isunix
More About
• “What Is the MATLAB Search Path?” on page 6-46
6-43
6 Managing Files in MATLAB
• To create an empty zip file, right-click white space, and then select New > Zip File.
• To create a populated zip file from selected files and folders, select the folders and files you want
to archive, right-click, and then select Create Zip File.
MATLAB creates an archive with a default name of Untitledn.zip, where n is an integer. Type over
the default file name to specify a descriptive name.
You also can create zip archives programmatically using the zip function. For example, to zip all files
with a .m and .mat extension in the current folder to a zip file archive named backup.zip, call:
zip('backup',{'*.m','*.mat'});
• Select, and then drag the file that you want to add onto the archive.
• Copy the file that you want to add to the archive. Then, select the archive to which you want to
add the file and paste the file into the archive.
1 Expand the zip file archive to view the archive contents, by clicking the associated + (expand)
button. By default, files within a zip file archive appear dimmed to indicate that they are not on
the MATLAB path.
2 Drag the file into a folder in the Current Folder browser.
MATLAB extracts the file and saves it to the folder where you dragged or pasted it.
To extract all the contents of a zip file, double-click the zip file in the Current Folder browser.
MATLAB creates a folder with the same name as the zip file, and extracts the entire contents of the
zip file into this folder.
6-44
Create and Extract from Zip Archives
To extract the contents of a zip file programmatically, use the unzip function. unzip also allows you
to specify a target folder. For example, to unzip the file, examples.zip, to a folder named
myfolder, call:
unzip('examples.zip','myfolder')
Note Archives created outside of MATLAB can be encrypted or password-protected. You cannot add
files to, or extract files from, protected archives from within MATLAB.
• Right-click a zip archive, and then from the context menu select Compare Against and specify
the folder to which you want to compare the contents of the zip archive.
• Expand a zip archive, right-click a file within it, and then from the context menu select Compare
Against. Specify the file to which you want to compare the archived file.
See Also
unzip | zip
More About
• “Compare Files and Folders and Merge Files” on page 6-6
6-45
6 Managing Files in MATLAB
The order of folders on the search path is important. When files with the same name appear in
multiple folders on the search path, MATLAB uses the one found in the folder nearest to the top of
the search path.
• The MATLAB userpath folder, which is added to the search path at startup, and is the default
location for storing user files
• The folders defined as part of the MATLABPATH environment variable
• The folders provided with MATLAB and other MathWorks products, which are under
matlabroot/toolbox, where matlabroot is the folder displayed when you run matlabroot in
the Command Window
Class, package, private, and resources folders are special folders that cannot be specified
explicitly as part of the search path. A special folder is added to the search path implicitly when its
parent folder is specified as part of the path. To access the files and folders within a special folder,
you must add its parent folder to the path.
You can explicitly add folders to the search path for the files you run. For more information about
adding files to the search path, see “Change Folders on Search Path” on page 6-50.
By default, the userpath folder is also the startup folder when you start MATLAB by double-clicking
either the MATLAB shortcut on Windows systems or the MATLAB application on Mac systems.
6-46
What Is the MATLAB Search Path?
To determine whether a file is on the search path, run which filename. If the file is on the search
path, MATLAB returns the full path to the file.
To determine whether a file or folder is on the search path, use the Current Folder browser. Files and
folders not on the path are dimmed. To ensure that the Current Folder browser is set to indicate
whether a file or folder in on the search path, right-click any file or folder, and select the Indicate
Files Not on Path option.
Hover the pointer over any dimmed file or folder in the Current Folder browser to find out why it is
dimmed. A tooltip opens with an explanation. Frequently, the tooltip indicates that the file or folder is
not on the MATLAB path. If a tooltip does not appear, it may be disabled. To enable it, go the Home
tab and in the Environment section, click Preferences. Then, select MATLAB > Current
Folder. Select Show tooltip explaining why files are inaccessible to display the tooltip.
Run the path command to view all the folders on the MATLAB search path.
Alternatively, use the Set Path dialog box to view the entire MATLAB search path. On the Home tab,
in the Environment section, click Set Path. The Set Path dialog box opens, listing all folders on the
search path. For more information on using the Set Path dialog box, see “Change Folders on Search
Path” on page 6-50.
6-47
6 Managing Files in MATLAB
MATLAB saves search path information in the pathdef.m file. This file contains a series of full path
names, one for each folder on the search path.
When you change the search path, MATLAB uses it in the current session, but does not update
pathdef.m. To use the modified search path in the current and future sessions, save the changes
using savepath or the Save button in the Set Path dialog box. This updates pathdef.m.
In MATLAB Online, all changes to the search path are automatically saved.
See Also
userpath
6-48
What Is the MATLAB Search Path?
More About
• “Add Folders to the MATLAB Search Path at Startup” on page 6-55
• “Change Folders on Search Path” on page 6-50
6-49
6 Managing Files in MATLAB
In this section...
“Add or Remove Folders on the Search Path Programmatically” on page 6-50
“Change Folders on Search Path Interactively” on page 6-50
“Change Folders Using Current Folder Browser” on page 6-52
“Change Folders on Search Path Using MATLAB Editor” on page 6-53
You can programmatically and interactively add or remove folders and change the order of MATLAB
folders on the search path, for the current session and future sessions. When files with the same
name appear in multiple folders on the search path, MATLAB uses the one in the folder nearest to the
top of the search path.
addpath("c:\matlab\MyFolder")
You can remove one or more folders from the path using the rmpath function.
rmpath("c:\matlab\MyFolder")
To save changes to the search path across MATLAB sessions, use the savepath function. This
function also saves changes that you make interactively with the Set Path dialog box, from the
Current Folder browser, or in the MATLAB Editor.
In MATLAB Online, changes to the path are automatically saved. Therefore, calling savepath is not
necessary.
1 On the Home tab, in the Environment section, click Set Path. The Set Path dialog box appears.
Alternatively, you can access this dialog box using the pathtool function.
6-50
Change Folders on Search Path
2 Use the Add Folder or Add Folder with Subfolders button to add new folders to MATLAB
search path.
3 Use the Move Down and Move Up buttons to change the order of files on the search path. Files
contained in folders at the top of the search path have precedence over those in folders farther
down. For more information, see “Function Precedence Order”.
4 Apply or cancel the search path changes:
• To use the newly modified search path only in the current session, click Close.
• To reuse the newly modified search path in the current session and future sessions, click
Save, and then Close.
• To undo your changes, click Revert, and then Close.
• To restore the default search path, click Default, and then Close. The default search path
contains only folders provided by MathWorks.
Note The MATLAB (userpath) folder automatically moves to the top of the search path the next time
you start MATLAB. For more information about the userpath folder, see “userpath Folder on the
Search Path” on page 6-46.
6-51
6 Managing Files in MATLAB
In MATLAB Online, you can use the buttons at the top of the Set Path dialog box to change the folders
on the search path. To search for folders on the path, use the search field at the top of the Set Path
dialog box.
1 From the Current Folder browser, right-click the folder or select and then right-click multiple
folders to add or remove.
2 From the context menu, select Add to Path or Remove from Path, and then select an option:
• Selected Folders
• Selected Folders and Subfolders
Changes to the search path using this method do not persist in future MATLAB sessions. To save
these changes, use savepath.
6-52
Change Folders on Search Path
Changes to the search path using this method do not persist in future MATLAB sessions. To save
these changes, use savepath.
See Also
addpath | rmpath | savepath
More About
• “What Is the MATLAB Search Path?” on page 6-46
6-53
6 Managing Files in MATLAB
To use your files with a new MATLAB version or with multiple versions, do one of the following:
• For each version, add the folders containing your files to the search path. Save the search path
(that is, save the pathdef.m file) where that version of MATLAB can access it.
• Include addpath statements in the startup.m file. Use the same startup.m file with the
multiple versions of MATLAB.
Including addpath statements in the startup.m file also allows you to use your files with MATLAB
on different platforms.
See Also
addpath
More About
• “Startup Options in MATLAB Startup File” on page 1-19
6-54
Add Folders to the MATLAB Search Path at Startup
addpath /home/username/mytools
For more information on creating a startup.m file with addpath statements, see “Startup Options
in MATLAB Startup File” on page 1-19.
Windows
To set the MATLABPATH environment variable in Windows, from the Windows Control Panel, go to
System and select Advanced system settings. Click the Environment Variables... button. Click
New... or Edit... to create or edit the MATLABPATH environment variable. In the dialog box that
appears, set the variable name to MATLABPATH and the variable value to a semicolon-separated list of
folders you want to add to the search path. For example, to add two folders, c:\matlab_files
\myfolder1 and c:\matlab_files\myfolder2, to the MATLABPATH environment variable, enter
c:\matlab_files\myfolder1;c:\matlab_files\myfolder2 as the variable value. Click OK to
set the variable and exit the dialog box. Restart MATLAB for the new settings to take effect.
To set the environment variable from a command window, run the command set
MATLABPATH=folders, where folders is a semicolon-separated list of folders. For example,
suppose that you want to add two folders, c:\matlab_files\myfolder1 and c:\matlab_files
\myfolder2, to the MATLABPATH environment variable. Run the command
set MATLABPATH=c:\matlab_files\myfolder1;c:\matlab_files\myfolder2
Once the environment variable is set, you must start MATLAB from the same command window for
the settings to take effect. The environment variable persists only as long as the command window is
open.
To set the MATLABPATH environment variable in UNIX and Mac, in a terminal, run the command
export MATLABPATH=folders, where folders is a colon-separated list of folders.
For example, suppose that you want to add two folders, /home/j/Documents/MATLAB/mine and /
home/j/Documents/MATLAB/research, to the MATLABPATH environment variable on a UNIX
platform. Run the command
export MATLABPATH=/home/j/Documents/MATLAB/mine:/home/j/Documents/MATLAB/research
6-55
6 Managing Files in MATLAB
Once the environment variable is set, you must start MATLAB from the same shell for the settings to
take effect. The environment variable persists only as long as the shell remains open.
Note If you are using a C shell (csh or tcsh), the command for setting the MATLABPATH
environment variable is setenv MATLABPATH folders.
To add the folders for all future MATLAB sessions, set the MATLABPATH environment variable as part
of your shell configuration script.
See Also
More About
• “What Is the MATLAB Search Path?” on page 6-46
• “Change Folders on Search Path” on page 6-50
6-56
Assign userpath as Startup Folder (Macintosh or UNIX)
Using a bash shell, set the MATLAB_USE_USERWORK environment variable so that userpath will be
used as the startup folder.
export MATLAB_USE_USERWORK=1
From that shell, start MATLAB. Next, verify the current folder in MATLAB.
pwd
/Users/smith/Documents/MATLAB
Confirm that this is the same as the folder defined for userpath.
userpath
/Users/smith/Documents/MATLAB;
path
/Users/smith/Documents/MATLAB
/Users/smith/Applications/MATLAB/R2009a/toolbox/matlab/general
/Users/smith/Applications/MATLAB/R2009a/toolbox/matlab/ops
...
6-57
6 Managing Files in MATLAB
When there is a problem with the search path, you cannot use MATLAB successfully.
• You save the search path on a Windows platform, and then try to use the same pathdef.m file on
a Linux platform.
• The pathdef.m file becomes corrupt, invalid, renamed, or deleted.
• MATLAB cannot locate the pathdef.m file.
When MATLAB starts, if there is a problem with the search path, a message such as the following
appears:
Warning: MATLAB did not appear to successfully set the search
path...
For problems with the search path, try these recovery steps. Proceed from one step to the next only
as necessary.
a Run
which pathdef
b If you want MATLAB to use the pathdef.m file at another location, make corrections. For
example, delete the incorrect pathdef.m file and ensure the correct pathdef.m file is in a
location that MATLAB can access.
2 Look for and correct problems with the pathdef.m and startup.m files:
a Open pathdef.m and startup.m in a text editor. Depending on the problem, you might not
be able to open the pathdef.m file.
b Look for obvious problems, such as invalid characters or path names.
c Make corrections and save the files.
d Restart MATLAB to ensure that the problem does not recur.
3 Try to correct the problem using the Set Path dialog box:
a Restore the default search path and save it. See “Change Folders on Search Path” on page 6-
50. Depending on the problem, you might not be able to open the dialog box.
b Restart MATLAB to ensure that the problem does not recur.
4 Restore the default search path using functions:
a Run restoredefaultpath, which sets the search path to the default and stores it in
matlabroot/toolbox/local.
b If restoredefaultpath seems to correct the problem, run savepath.
c Restart MATLAB to ensure that the problem does not recur.
a Run
restoredefaultpath; matlabrc
6-58
Path Unsuccessfully Set at Startup
savepath('path_to_your_startup_folder/pathdef.m')
After correcting problems with the search path, make any changes to run your files. For example, add
the userpath folder or other folders to the search path.
6-59
6 Managing Files in MATLAB
The behavior varies by platform because it depends on the behavior of similar features in the
operating system.
If your task fails and the error message indicates it is because the folder is on the search path, then
do the following:
6-60
Troubleshoot Invalid or Unresponsive Windows Change Notification Handles
When MATLAB is unable to obtain a valid or responsive Change Notification Handle, it cannot
automatically detect changes to files and folders. For example, new functions added to an affected
folder might not be visible, and changed functions in memory might not be reloaded.
If your file system updates folder timestamps when files are added to folders, you can set your system
remote path policy to detect changes by testing the timestamps of folders. To do so, include these
commands in a startup.m file. For more information on creating a startup.m file, see “Startup
Options in MATLAB Startup File” on page 1-19.
system_dependent('RemotePathPolicy', 'TimecheckDir');
rehash path;
You might notice a performance degradation due to the time required to check the timestamps.
If your file system does not update folder timestamps (such as an NT file system), you can set your
system remote path policy to detect changes by rereading the affected folders at frequent intervals.
To do so, include these commands in a startup.m file.
system_dependent('RemotePathPolicy', 'Reload');
rehash path;
You might notice a significant performance degradation due to the time required to reread the
folders.
In some cases, detecting new files or changed files in folders affected by the invalid or unresponsive
change notification handles is not necessary. If detecting changes is not necessary, to provide
maximum performance, you can disable your system remote path policy. To do so, include these
commands in a startup.m file.
system_dependent('RemotePathPolicy', 'None');
rehash path;
6-61
6 Managing Files in MATLAB
• Show warning messages for all invalid or unresponsive change notification handles.
system_dependent('DirChangeHandleWarn', 'Always');
• Only show the first warning message about invalid or unresponsive change notification handles.
system_dependent('DirChangeHandleWarn', 'Once');
• Never show warning messages about invalid or unresponsive change notification handles.
system_dependent('DirChangeHandleWarn', 'Never');
To determine when Windows warns about invalid or unresponsive change notification handles, use
this command.
system_dependent('DirChangeHandleWarn', 'Status');
See Also
addpath | rehash
More About
• “What Is the MATLAB Search Path?” on page 6-46
• “Startup Options in MATLAB Startup File” on page 1-19
6-62
7
Editor Preferences
Editor/Debugger Preferences
In this section...
“General Preferences for the Editor/Debugger” on page 7-2
“Editor/Debugger Display Preferences” on page 7-3
“Editor/Debugger Tab Preferences” on page 7-4
“Editor/Debugger Language Preferences” on page 7-5
“Editor/Debugger Code Folding Preferences” on page 7-7
“Editor/Debugger Backup Files Preferences” on page 7-8
“Editor/Debugger Autoformatting Preferences” on page 7-9
“Editor/Debugger Automatic Completions Preferences” on page 7-10
“Editor/Debugger Saving Preferences” on page 7-13
You can customize the visual display and functionality of the Editor, Live Editor, and Debugger using
Editor/Debugger preferences.
You can specify which editor MATLAB uses, as well as how the MATLAB Editor and Live Editor
behave under various circumstances.
On the Home tab, in the Environment section, click Preferences. Select Editor/Debugger, and
then adjust preference options as described in the table below.
Preference Usage
Editor Select which editor you want the MATLAB desktop to
use when you edit a file:
• MATLAB Editor
• Text editor
If you select Text editor, specify the full path for the
editor application you want to use, such as Emacs or
vi. For example, c:/Applications/Emacs.exe.
7-2
Editor/Debugger Preferences
Preference Usage
Select Automatically open files when MATLAB
reaches a breakpoint to open a running program file
when MATLAB encounters a breakpoint in that file.
Automatic file changes Select Save changes upon clicking away from a
file if you want the Editor and Live Editor to
automatically save changes to a file when you click
away from the file. For the changes to be automatically
saved upon clicking away, you must have already saved
the file at least once.
You can change the appearance of the Editor and Live Editor.
On the Home tab, in the Environment section, click Preferences. Select Editor/Debugger >
Display, and then adjust preference options as described in the table below.
Preference Usage
General display options Select Highlight Current Line and select a color to
highlight the row with the cursor (also called the
caret).
7-3
7 Editor Preferences
Preference Usage
Select Show line numbers to display line numbers
along the left edge of the Editor and Live Editor
window.
Select Enable data tips in edit mode to display data
tips when you are editing a MATLAB code file. (Data
tips are always enabled in debug mode.)
You can specify the size of tabs and indents and details about how tabs behave in the Editor and Live
Editor.
7-4
Editor/Debugger Preferences
On the Home tab, in the Environment section, click Preferences. Select Editor/Debugger >
Tab, and then adjust preference options as described in the table below.
Option Usage
Tab size Specify the amount of space inserted when you press
the Tab key.
When you change the Tab size, it changes the tab size
for existing lines in that file, unless you also select Tab
key inserts spaces.
Indent size Specify the indent size for automatic indenting. To set
automatic indenting preferences, see “Editor/
Debugger Language Preferences” on page 7-5.
Tab key inserts spaces Select to insert a series of spaces when you press the
Tab key. Otherwise, a tab acts as one space whose
length is equal to the Tab size.
Emacs-style Tab key smart indenting Specifies an indenting style similar to the style that the
Emacs editor uses.
You can specify how various languages appear in the Editor and Live Editor. MATLAB applies
language preferences based on the file extension of the file that is open.
On the Home tab, in the Environment section, click Preferences. Select Editor/Debugger >
Language, and then adjust preference options as described in the table below. In MATLAB Online, to
set language preferences, select Editor/Debugger > MATLAB Language or Editor/Debugger >
Other Languages.
Preference Usage
Language Select the language for which you want to set preferences.
7-5
7 Editor Preferences
Preference Usage
Syntax highlighting Select Enable syntax highlighting to have the Editor and
Live Editor use different colors for different language
constructs. Then, adjust the colors you want to use for each
language element.
Consider selecting:
7-6
Editor/Debugger Preferences
Preference Usage
Indenting Select Apply smart indenting while typing to
automatically:
• Indent the body of loops within the start and end of the
loop statement.
• Align subsequent lines with lines you indent using tabs or
spaces.
• Indent functions as specified with the Function
indenting format option.
Code folding enables you to expand and collapse blocks of MATLAB code that you want to hide when
you are not currently working on them.
On the Home tab, in the Environment section, click Preferences. Select Editor/Debugger >
Code Folding, and then adjust preference options as described in the table below.
For examples and detailed information about code folding, see “Fold Code”.
Option Usage
Enable Code Folding Specifies whether you want code folding enabled for
the programming constructs that have their
corresponding Enable check box selected.
7-7
7 Editor Preferences
Option Usage
Enable Specifies whether you want code folding enabled for
the corresponding Programming Construct.
If you select this option for any construct, but clear the
Enable Code Folding option, the construct will not
have code folding enabled.
Fold Initially Specifies whether the corresponding Programming
Construct displays collapsed (folded) the first time
that you open a MATLAB file.
You can specify if, when, and how you want MATLAB to automatically back up files that are open in
the Editor.
On the Home tab, in the Environment section, click Preferences. Select Editor/Debugger >
Backup Files, and then adjust preference options as described in the table below.
Backup files preferences do not apply in the Live Editor and are not available in MATLAB Online.
Preference Usage
Automatically create backup files while working Select to have MATLAB automatically save a copy of
in the MATLAB Editor the files you are currently editing.
Save options Save the backup every: n minutes specifies how
often you want MATLAB to save a copy of the file you
are editing.
Save untitled files saves a copy of new, untitled, files
to Untitled.asv.
7-8
Editor/Debugger Preferences
Preference Usage
Location Source file directories specifies that you want
backup files stored in the same folder as the files being
edited.
For more information about automatically creating backup copies of modified files in the Editor, see
“Save and Back Up Code”.
You can quickly format live scripts and functions using autoformatting markup in the Live Editor. You
can enable and disable autoformatting as a whole, or as individual options.
On the Home tab, in the Environment section, click Preferences. Select Editor/Debugger >
Autoformatting, and then adjust preference options as described in this table.
Preference Usage
Enable autoformatting in Live Editor Select to enable autoformatting options in the Live
Editor. Once enabled, options can then be enabled or
disabled individually.
Text format Select *italic*, **bold** to enable bold and italic
formatting using asterisks (*).
Select _italic_, __bold__ to enable bold and italic
formatting using underscores (_).
Select `monospace`, |monospace| to enable
monospace autoformatting.
Section break Select %%, ***, or --- for section break to enable
inserting section breaks by entering %%, ***, or ---
and then Enter.
Select %% text for section break and heading to
enable inserting section breaks with heading 1 style
headings by entering %%text and then Enter.
Insert Options Select $LaTeX$ for LaTeX equation to enable
converting LaTeX expressions into equations using the
format $LaTeX$.
7-9
7 Editor Preferences
Preference Usage
Select URL for hyperlink to enable converting
internet paths automatically to hyperlinks.
Select <URL> for hyperlink to enable converting
internet paths to hyperlinks using the format <URL>.
Select [Label](URL) for labeled hyperlink to enable
converting internet paths to labeled hyperlinks using
the format [Label](URL).
Select (TM), (SM), (R), and (C) for trademark,
service mark, and copyright symbols to enable
inserting trademark and copyright symbols (™, ℠, ®,
and ©) using the format (TM), (SM), (R), and (C).
Text Style Select #text for title to enable inserting titles using
the format #text.
Select ##text, ###text, or ####text for heading
to enable inserting headings using the format ##text
for heading 1, ###text for heading 2, or ####text
for heading 3.
Select Automatic bulleted lists (*, +, or -) to enable
creating bulleted lists by entering *, +, or - followed
by a space.
Select Automatic numbered lists (1., 2., etc.) to
enable creating numbered lists by entering 1., 2., and
so on, followed by a space.
For more information about autoformatting in the Live Editor, see “Autoformatting”.
You can change how MATLAB suggests and completes names in the Editor, Live Editor, and App
Designer. You also can change whether MATLAB automatically completes block endings, parentheses,
quotes, comments, character vectors, and strings in the Editor, Live Editor, and App Designer.
On the Home tab, in the Environment section, click Preferences. Select Editor/Debugger >
Automatic Completions, and then adjust preference options as described in this table.
Preference Usage
Suggestions and completions Select Show suggestions automatically to
automatically show suggestions as you type in the
Editor, Live Editor, and App Designer. Clear Show
suggestions automatically to show suggestions only
when you press Ctrl+Space or press the Tab key.
7-10
Editor/Debugger Preferences
Preference Usage
Select Use tab to show suggestions (in addition to
ctrl+space) to show suggestions when you press the
Tab key in the Editor, Live Editor, and App Designer.
Clear Use tab to show suggestions (in addition to
ctrl+space) to show suggestions only when you press
Ctrl+Space.
7-11
7 Editor Preferences
Preference Usage
Autocomplete on new line
exist("exceptionally_long_file_name.txt")
exist("exceptionally_long" + ...
"_file_name.txt")
• Select Parentheses () to automatically split
parentheses when you press Enter. For example,
place your cursor after the number 10 and the
comma in the command below and press Enter.
plot(x,y,'--gs','LineWidth',2,'MarkerSize',10,'MarkerEd
plot(x,y,'--gs','LineWidth',2,'MarkerSize',10, ...
'MarkerEdgeColor','b')
7-12
Editor/Debugger Preferences
Preference Usage
Autocomplete block endings
You can specify if and when MATLAB Online saves files automatically.
On the Home tab, in the Environment section, click Preferences. Select Editor/Debugger >
Saving, and then adjust preference options as described in this table.
Preference Usage
Autosave options Select Save files periodically to have MATLAB Online
periodically save the files you are currently editing.
In the Every: n minutes field, specify how often you
want MATLAB to save the files you are editing. By
default, MATLAB saves files every 1 minute.
Select Save changes upon clicking away from a
file if you want the Editor and Live Editor to
automatically save changes to a file when you click
away from the file. For the changes to be automatically
saved upon clicking away, you must have already saved
the file at least once.
7-13
7 Editor Preferences
In this section...
“Code Analyzer Preferences” on page 7-14
“Search for Messages in the Code Analyzer Preferences” on page 7-15
On the Home tab, in the Environment section, click Preferences. Select Code Analyzer, and
then adjust preference options as described in the table below.
Option Usage
Enabled Integrated Warning and Error Messages Specify whether you want to display Code Analyzer
message indicators, such as the underlining of code
and the message indicator bar, for documents open in
the Editor.
7-14
Code Analyzer Preferences
Option Usage
Search field Searches the list of Code Analyzer messages that
display below the search field. For details, see “Search
for Messages in the Code Analyzer Preferences” on
page 7-15.
Code Analyzer message settings Select or clear messages to enable or suppress their
appearance in your Editor documents.
Note If you do not have the MATLAB Compiler™ installed, the Code Analyzer preferences pane does
not display the MATLAB Compiler (deployment) messages category.
7-15
7 Editor Preferences
In a given category Click the down arrow to the right of the You want to review messages that
search field, click Show Messages in describe coding practices that make it
Category, and then click the category difficult for others to use your code.
you want.
Click the down arrow to the right of the
search field, select Show Messages in
Category, and then select Aesthetics
and Readability.
7-16
Code Analyzer Preferences
To display Code Analyzer error messages that contain the word variable and are disabled:
1 Click the down arrow in the search field, and then select Show All Errors.
The search field now contains severity:error variable enabled:false. Only the messages
that fulfill those requirements appear in the Preferences pane. To restore the list of all messages,
click the clear search button .
The Show All Errors and Show Disabled Messages options are not available in MATLAB Online.
See Also
More About
• “Check Code for Errors and Warnings Using the Code Analyzer”
7-17
7 Editor Preferences
This file configures the Code Analyzer checks performed for the resources folder's parent folder
and its subfolders. The configuration is cached at the start of a MATLAB session. The MATLAB Editor
does not automatically get the latest configuration when you add a new configuration file to a
resources folder or update an existing file during a MATLAB session. To refresh the cache, call
matlab.codeanalysis.refreshConfiguration.
Verify that the file is a valid JSON file using the matlab.codeanalysis.validateConfiguration
function.
"baseConfiguration" : "closestParentFolder",
"checks":
{
"MyOwnCheck" :
{
"rule":
{
"template": "functionCall",
"functionNames" : "evalin"
},
"severity" : "error",
"messageText" : "Do not use evalin.",
7-18
Configure Code Analyzer
"enabled" : true
},
"FCNIL" :
{
"severity" : "error",
"limit" : 10,
"enabled": true
},
"FCNOL" :
{
"severity" : "error",
"messageText": "Too many outputs."
"limit" : 15,
"enabled": true,
},
"AGROW" :
{
"severity" : "info",
"messageText" : "Growing array in a loop is not recommended",
"enabled" : false
}
}
}
• "closestParentFolder" (default) — Use the configuration file found in the closest parent
folder. If "baseConfiguration" is not defined, then the "closestParentFolder" setting is
used.
• "factory" — Use the standard MATLAB Code Analyzer configuration.
7-19
7 Editor Preferences
7-20
Configure Code Analyzer
To identify the check ID for checks in a given file, use codeIssues. For a full list of configurable
checks, see “Index of Code Analyzer Checks” on page 7-22.
See Also
Apps
Code Analyzer
Objects
codeIssues
Functions
matlab.codeanalysis.validateConfiguration |
matlab.codeanalysis.refreshConfiguration
Related Examples
• “Check Code for Errors and Warnings Using the Code Analyzer”
• “MATLAB Code Analyzer Report”
• “Index of Code Analyzer Checks” on page 7-22
7-21
7 Editor Preferences
Incomplete Analysis
Check ID Severity Message Can Be Disabled?
TMMSG Error More than 10,000 Code Analyzer false
messages were generated, leading to
some being deleted.
TMSMS Error More than 1,000 parse error messages false
were generated, leading to some being
deleted.
MXASET Error The file is too complex to analyze. false
Simplify the code to improve code
maintainability. For example, reduce
the number of operations in
expressions.
QUIT Error Code analysis did not complete. Code false
Analyzer encountered an error.
NOSPC Error The file is too complex to analyze. false
Refactor the code to improve code
maintainability. For example, reduce
the nesting level of conditions or
functions.
MBIG Error Code analysis did not complete. File false
VAR_FILE is too large.
NOFIL Error Unable to open file VAR_FILE. File is false
not found.
MDOTM Error Unable to run code analysis. VAR_FILE false
has an invalid file extension.
BDCFG Error Unable to run code analysis due to false
invalid Code Analyzer configuration
file. Run
matlab.codeanalysis.validateConfigurat
ion(VAR_NAME) to identify specific
issues.
BDFIL Error Unable to run code analysis due to false
invalid MATLAB file name. MATLAB file
names must start with a letter and
contain only letters, numbers or
underscores.
RDERR Error Unable to read file VAR_FILE. false
7-22
Index of Code Analyzer Checks
Syntax Errors
7-23
7 Editor Preferences
7-24
Index of Code Analyzer Checks
7-25
7 Editor Preferences
7-26
Index of Code Analyzer Checks
7-27
7 Editor Preferences
7-28
Index of Code Analyzer Checks
7-29
7 Editor Preferences
7-30
Index of Code Analyzer Checks
7-31
7 Editor Preferences
7-32
Index of Code Analyzer Checks
7-33
7 Editor Preferences
Bugs
Check ID Severity Message Can Be Disabled?
IFBDUP Error This condition has no effect because all true
blocks in this if statement are identical.
Remove the condition or change the
code blocks.
IFCDUP Error The statements under this true
VAR_RESERVED_WORD condition
cannot be reached because it is a
duplicate of the
VAR_RESERVED_WORD condition on
line VAR_NUMBER. Remove or change
the condition.
PFUIXE Error The index variable VAR_NAME might true
be used after the PARFOR loop on line
VAR_NUMBER, but it is unavailable
after the loop.
PFBFN Error The function VAR_NAME inside a true
PARFOR loop might not access the
correct workspace.
PFIFN Error The function VAR_NAME might make true
an invalid workspace access inside the
PARFOR loop.
PFTUSE Error The temporary variable VAR_NAME is true
used after the PARFOR loop on line
VAR_NUMBER, but its value is not
available after the loop.
PFRNC Error The variable VAR_NAME is used like a true
PARFOR reduction variable, but it has
additional (invalid) uses.
RHSFN Error The expression cannot be assigned to true
multiple values.
FNAN Error Use ISNAN when comparing values to true
NaN.
FUNFUN Error The first input argument must be a true
function handle. Did you mean
'@VAR_NAME'?
MOCUP Error The variable VAR_NAME is an uplevel true
variable, invalid in a function called by
onCleanup.
MDUPC Error The case value VAR_NAME is a true
duplicate of one on line VAR_NUMBER.
MNANC Error NaN never compares equal to any true
value, so this case will never be
matched.
7-34
Index of Code Analyzer Checks
7-35
7 Editor Preferences
Custom Checks
Check ID Severity Message Can Be Disabled?
FCNIL Warning Function has more than VAR_NUMBER true
input arguments. This makes the
function difficult to understand and
maintain.
FCNOL Warning Function has more than VAR_NUMBER true
output arguments. This makes the
function difficult to understand and
maintain.
FCNLL Warning Function has more than VAR_NUMBER true
lines. This makes the function difficult
to understand and maintain.
LLMNC Warning Line has more than VAR_NUMBER true
characters (including whitespaces).
This makes the line difficult to
understand and maintain.
MNCSN Warning This control statement is deeply nested true
(nesting level = VAR_NUMBER) and
might have more deeply nested control
statements. This makes the code
difficult to understand and maintain.
7-36
Index of Code Analyzer Checks
Compatibility Considerations
Check ID Severity Message Can Be Disabled?
IMPORTDYN Warning In a future release, IMPORT will not true
accept variable names, function calls,
or operators. Use literal char vectors
instead.
REDEFGI Warning Declaring an input or output variable to true
be global might not be supported in a
future release.
REDEFGG Warning Declaring a variable to be global more true
than once might not be supported in a
future release.
MCPDC Error Specifying both the 'Constant' and true
'Dependent' attributes on the same
property is not supported.
NOV6 Warning 'v6' will be removed in a future release. true
There is no simple replacement for this.
LEGINTPAR Error Using integers to specify location not true
supported. Use the location parameter
name and value pair instead.
7-37
7 Editor Preferences
7-38
Index of Code Analyzer Checks
7-39
7 Editor Preferences
7-40
Index of Code Analyzer Checks
7-41
7 Editor Preferences
7-42
Index of Code Analyzer Checks
7-43
7 Editor Preferences
7-44
Index of Code Analyzer Checks
7-45
7 Editor Preferences
7-46
Index of Code Analyzer Checks
7-47
7 Editor Preferences
7-48
Index of Code Analyzer Checks
7-49
7 Editor Preferences
7-50
Index of Code Analyzer Checks
7-51
7 Editor Preferences
7-52
Index of Code Analyzer Checks
7-53
7 Editor Preferences
7-54
Index of Code Analyzer Checks
7-55
7 Editor Preferences
7-56
Index of Code Analyzer Checks
7-57
7 Editor Preferences
7-58
Index of Code Analyzer Checks
7-59
7 Editor Preferences
7-60
Index of Code Analyzer Checks
7-61
7 Editor Preferences
7-62
Index of Code Analyzer Checks
7-63
7 Editor Preferences
7-64
Index of Code Analyzer Checks
7-65
7 Editor Preferences
7-66
Index of Code Analyzer Checks
7-67
7 Editor Preferences
7-68
Index of Code Analyzer Checks
7-69
7 Editor Preferences
7-70
Index of Code Analyzer Checks
7-71
7 Editor Preferences
7-72
Index of Code Analyzer Checks
7-73
7 Editor Preferences
7-74
Index of Code Analyzer Checks
7-75
7 Editor Preferences
7-76
Index of Code Analyzer Checks
7-77
7 Editor Preferences
7-78
Index of Code Analyzer Checks
7-79
7 Editor Preferences
7-80
Index of Code Analyzer Checks
7-81
7 Editor Preferences
7-82
Index of Code Analyzer Checks
7-83
7 Editor Preferences
7-84
Index of Code Analyzer Checks
7-85
7 Editor Preferences
7-86
Index of Code Analyzer Checks
7-87
7 Editor Preferences
7-88
Index of Code Analyzer Checks
7-89
7 Editor Preferences
7-90
Index of Code Analyzer Checks
7-91
7 Editor Preferences
7-92
Index of Code Analyzer Checks
7-93
7 Editor Preferences
7-94
Index of Code Analyzer Checks
Good Practices
Check ID Severity Message Can Be Disabled?
VTFIN Warning VAR_NAME must be the first input true
argument to the VAR_NAME function.
TLEV Warning VAR_NAME could be very inefficient true
unless it is a top-level statement in its
function.
SHVAU Warning Confusing usage of name VAR_NAME true
on lines VAR_NUMBER and
VAR_NUMBER. Initialize VAR_NAME
before line VAR_NUMBER to make it a
shared variable or rename VAR_NAME
on line VAR_NUMBER to disambiguate.
PFRNI Warning Do not specify the increment explicitly. true
The parfor loop can only use an
increment of one.
PFGP Warning Avoid assigning to GLOBAL or true
PERSISTENT variable VAR_NAME
inside a PARFOR loop.
PFGV Warning Avoid using GLOBAL variable true
VAR_NAME in a PARFOR loop.
PFEVB Warning Using EVALIN('base') or true
ASSIGNIN('base') inside a PARFOR
loop refers to the worker machines'
base workspaces.
PFUIXW Warning The index variable VAR_NAME might true
be used after the PARFOR loop on line
VAR_NUMBER. The value set on this
line is not available after the loop.
PFOUS Warning The output variable VAR_NAME might true
not be used after the PARFOR loop.
PFIIN Warning The input variable VAR_NAME should true
be initialized before the PARFOR loop.
PFRIN Warning The reduction variable VAR_NAME true
might not be set before the PARFOR
loop.
PFRUS Warning The reduction variable VAR_NAME true
might not be used after the PARFOR
loop.
PFTUSW Warning The temporary variable VAR_NAME true
might be used after the PARFOR loop
on line VAR_NUMBER. The value set on
this line is not available after the loop.
7-95
7 Editor Preferences
7-96
Index of Code Analyzer Checks
7-97
7 Editor Preferences
7-98
Index of Code Analyzer Checks
7-99
7 Editor Preferences
7-100
Index of Code Analyzer Checks
Unset Variables
Unused Constructions
7-101
7 Editor Preferences
7-102
Index of Code Analyzer Checks
Suggested Improvements
Check ID Severity Message Can Be Disabled?
LERR Info LASTERR and LASTERROR are not true
recommended. Use an identifier on the
CATCH block instead.
EVLC Info Using 'evalc' with two arguments is not true
recommended. Use try/catch
statements instead to make code more
clear and efficient.
RAND Info RAND or RANDN with the 'seed', true
'state', or 'twister' inputs is not
recommended. Use RNG instead.
HOUGH Info HOUGH(BW,'ThetaResolution',VAL) is true
not recommended. Use
HOUGH(BW,'Theta',-90:VAL:(90-VAL) )
instead.
THOUR Info 'hour' with serial date number or text true
inputs is not recommended. With
appropriate code changes, use
'datetime' as input instead.
TMNTH Info 'month' with serial date number or text true
inputs is not recommended. With
appropriate code changes, use
'datetime' as input instead.
TMNUT Info 'minute' with serial date number or text true
inputs is not recommended. With
appropriate code changes, use
'datetime' as input instead.
TNDAY Info 'day' with serial date number or text true
inputs is not recommended. With
appropriate code changes, use
'datetime' as input instead.
TSCND Info 'second' with serial date number or text true
inputs is not recommended. With
appropriate code changes, use
'datetime' as input instead.
TQURT Info 'quarter' with serial date number or true
text inputs is not recommended. With
appropriate code changes, use
'datetime' as input instead.
TYEAR Info 'year' with serial date number or text true
inputs is not recommended. With
appropriate code changes, use
'datetime' as input instead.
7-103
7 Editor Preferences
7-104
Index of Code Analyzer Checks
7-105
7 Editor Preferences
7-106
Index of Code Analyzer Checks
7-107
7 Editor Preferences
7-108
Index of Code Analyzer Checks
7-109
7 Editor Preferences
7-110
Index of Code Analyzer Checks
7-111
7 Editor Preferences
7-112
Index of Code Analyzer Checks
7-113
7 Editor Preferences
7-114
Index of Code Analyzer Checks
7-115
7 Editor Preferences
7-116
Index of Code Analyzer Checks
7-117
7 Editor Preferences
Readability Improvements
Check ID Severity Message Can Be Disabled?
ASGSL Info Assignment to variable might be true
unnecessary.
COMNL Info Newline following comma acts as a row true
separator. Replace the comma with a
semicolon to make the row separation
clearer. Alternatively, use an ellipsis
(...) to continue the current row on the
next line.
SPERR Info ERROR takes SPRINTF-like arguments true
directly.
SPWRN Info WARNING takes SPRINTF-like true
arguments directly.
NCHKE Info Use NARGOUTCHK without ERROR. true
DSPSP Info 'disp(sprintf(...))' can usually be true
replaced by 'fprintf(...\n)'.
DSPSY Info 'display(sprintf(...))' can usually be true
replaced by 'fprintf(...\n)'.
STLOW Info In this comparison the call to UPPER/ true
LOWER is unnecessary.
FLUDLR Info For readability, consider using true
rot90(x,2) instead of flipud(fliplr(x)) or
fliplr(flipud(x)).
RPMT1 Info For readability, consider using true
'ones(x,y)' instead of 'repmat(1,x,y)'.
RPMT0 Info For readability, consider using true
'zeros(x,y)' instead of 'repmat(0,x,y)'.
RPMTT Info For readability, consider using true
'true(x,y)' instead of 'repmat(true,x,y)'.
RPMTF Info For readability, consider using true
'false(x,y)' instead of 'repmat(false,x,y)'.
RPMTI Info For readability, consider using 'Inf(x,y)' true
instead of 'repmat(Inf,x,y)'.
RPMTN Info For readability, consider using true
'NaN(x,y)' instead of 'repmat(NaN,x,y)'.
PSIZE Info NUMEL(x) is usually faster than true
PROD(SIZE(x)).
LOGL Info Use 'true' or 'false' instead of true
'logical(1)' or 'logical(0)'.
ISCHR Info Use ISCHAR instead of comparing the true
class to 'char'.
7-118
Index of Code Analyzer Checks
7-119
7 Editor Preferences
Formatting Suggestions
Performance Improvements
7-120
Index of Code Analyzer Checks
7-121
7 Editor Preferences
7-122
Index of Code Analyzer Checks
7-123
7 Editor Preferences
System Objects
Check ID Severity Message Can Be Disabled?
SONUMIN Error If 'stepImpl' accepts variable number of true
inputs, then you must define a
'getNumInputsImpl' method.
SONUMOUT Error If 'stepImpl' returns variable number of true
outputs, then you must define a
'getNumOutputsImpl' method.
SODEPPROP Warning Dependent properties are not true
supported for MATLAB System blocks.
VAR_NAME property is not included on
System block.
7-124
Index of Code Analyzer Checks
Unsupported Features
Check ID Severity Message Can Be Disabled?
MCADE Warning Using Description as an attribute is true
unsupported and might have been
changed without notice or might be
removed without notice. There is no
simple replacement for this.
AWTIUD Warning 'awtinvoke' is unsupported and might true
have been changed without notice or
might be removed without notice. With
appropriate code changes, use
javaMethodEDT instead.
AXCHUD Warning 'axescheck' is unsupported and might true
have been changed without notice or
might be removed without notice.
There is no simple replacement for this.
FEATUD Warning 'feature' and flags passed to it are true
unsupported and might have been
changed without notice or might be
removed without notice. There is no
simple replacement for this.
7-125
7 Editor Preferences
7-126
Index of Code Analyzer Checks
Behavior Changes
Check ID Severity Message Can Be Disabled?
SHVAI Warning Explicitly define shared variables in the true
parent function before calling the
nested function. MATLAB does not
share uninitialized variables between a
nested function and the parent
function.
LENEMP Warning Passing in text with no characters will true
omit the object from appearing in the
legend. To revert to the old behavior,
use a whitespace character instead of
text with no characters.
INTRPC Warning 'interp1(...,'cubic')' changed in R2020b true
to perform cubic convolution. To
continue using shape-preserving
piecewise cubic interpolation, use
'interp1(...,'pchip')' instead.
IDISVARHIGH Warning Variable must be explicitly defined true
before first use. In some cases, the
definition was not required in previous
releases, but it is now required.
LEGPVPAIR Warning 'legend' has changed and might true
interpret the name of an argument as a
legend property instead of a label. To
include a label with the same name as
a legend property, specify the labels
using a cell array or string array. Refer
to the documentation for a list of
affected property names.
7-127
7 Editor Preferences
7-128
Index of Code Analyzer Checks
7-129
7 Editor Preferences
7-130
Index of Code Analyzer Checks
7-131
7 Editor Preferences
7-132
Index of Code Analyzer Checks
7-133
7 Editor Preferences
7-134
Index of Code Analyzer Checks
7-135
7 Editor Preferences
7-136
Index of Code Analyzer Checks
7-137
7 Editor Preferences
7-138
Index of Code Analyzer Checks
7-139
7 Editor Preferences
7-140
Index of Code Analyzer Checks
7-141
7 Editor Preferences
7-142
Index of Code Analyzer Checks
7-143
7 Editor Preferences
7-144
Index of Code Analyzer Checks
7-145
7 Editor Preferences
7-146
Index of Code Analyzer Checks
7-147
7 Editor Preferences
7-148
Index of Code Analyzer Checks
7-149
7 Editor Preferences
7-150
Index of Code Analyzer Checks
7-151
7 Editor Preferences
7-152
Index of Code Analyzer Checks
7-153
7 Editor Preferences
7-154
Index of Code Analyzer Checks
7-155
7 Editor Preferences
7-156
Index of Code Analyzer Checks
7-157
7 Editor Preferences
7-158
Index of Code Analyzer Checks
7-159
7 Editor Preferences
7-160
Index of Code Analyzer Checks
7-161
7 Editor Preferences
7-162
Index of Code Analyzer Checks
7-163
7 Editor Preferences
7-164
Index of Code Analyzer Checks
7-165
7 Editor Preferences
7-166
Index of Code Analyzer Checks
7-167
7 Editor Preferences
7-168
Index of Code Analyzer Checks
7-169
7 Editor Preferences
7-170
Index of Code Analyzer Checks
7-171
7 Editor Preferences
7-172
Index of Code Analyzer Checks
7-173
7 Editor Preferences
7-174
Index of Code Analyzer Checks
7-175
7 Editor Preferences
7-176
Index of Code Analyzer Checks
7-177
7 Editor Preferences
7-178
Index of Code Analyzer Checks
7-179
7 Editor Preferences
7-180
Index of Code Analyzer Checks
7-181
7 Editor Preferences
7-182
Index of Code Analyzer Checks
7-183
7 Editor Preferences
7-184
Index of Code Analyzer Checks
7-185
7 Editor Preferences
7-186
Index of Code Analyzer Checks
7-187
7 Editor Preferences
7-188
Index of Code Analyzer Checks
7-189
7 Editor Preferences
7-190
Index of Code Analyzer Checks
7-191
7 Editor Preferences
7-192
Index of Code Analyzer Checks
7-193
7 Editor Preferences
7-194
Index of Code Analyzer Checks
7-195
7 Editor Preferences
7-196
Index of Code Analyzer Checks
7-197
7 Editor Preferences
7-198
Index of Code Analyzer Checks
7-199
7 Editor Preferences
7-200
Index of Code Analyzer Checks
7-201
7 Editor Preferences
7-202
Index of Code Analyzer Checks
7-203
7 Editor Preferences
7-204
Index of Code Analyzer Checks
7-205
7 Editor Preferences
7-206
Index of Code Analyzer Checks
7-207
7 Editor Preferences
7-208
Index of Code Analyzer Checks
7-209
7 Editor Preferences
7-210
Index of Code Analyzer Checks
7-211
7 Editor Preferences
7-212
Index of Code Analyzer Checks
7-213
7 Editor Preferences
7-214
Index of Code Analyzer Checks
7-215
7 Editor Preferences
7-216
Index of Code Analyzer Checks
7-217
7 Editor Preferences
7-218
Index of Code Analyzer Checks
7-219
7 Editor Preferences
7-220
Index of Code Analyzer Checks
7-221
7 Editor Preferences
7-222
Index of Code Analyzer Checks
7-223
7 Editor Preferences
7-224
Index of Code Analyzer Checks
7-225
7 Editor Preferences
7-226
Index of Code Analyzer Checks
7-227
7 Editor Preferences
7-228
Index of Code Analyzer Checks
7-229
7 Editor Preferences
7-230
Index of Code Analyzer Checks
7-231
7 Editor Preferences
7-232
Index of Code Analyzer Checks
7-233
7 Editor Preferences
7-234
Index of Code Analyzer Checks
7-235
7 Editor Preferences
7-236
Index of Code Analyzer Checks
7-237
7 Editor Preferences
7-238
Index of Code Analyzer Checks
7-239
7 Editor Preferences
7-240
Index of Code Analyzer Checks
7-241
7 Editor Preferences
7-242
Index of Code Analyzer Checks
See Also
Code Analyzer | codeIssues | fix | checkcode
Related Examples
• “Configure Code Analyzer” on page 7-18
7-243
8
Add-Ons
In this section...
“Get Add-Ons” on page 8-2
“Install Add-Ons from File” on page 8-3
“Default Add-On Installation Folder” on page 8-3
“Manage Add-Ons” on page 8-4
“Update Add-Ons” on page 8-4
“Run Apps” on page 8-4
Add-ons encompass a wide variety of resources, including products, apps, support packages, and
toolboxes. They extend the capabilities of MATLAB with functionality for additional tasks and
applications.
Get Add-Ons
To find and install add-ons, go to the Home tab and, in the Environment section, click the
Add-Ons icon. The Add-On Explorer opens and displays the list of available add-ons.
You must have an active internet connection to get add-ons using the Add-On Explorer.
8-2
Get and Manage Add-Ons
To find add-ons, use the search bar, or browse through the available categories on the left side of the
Add-On Explorer window. Select an add-on from the list to view additional information about it, such
as what files it includes and what documentation is available
To install an add-on, select it from the list. Then, select from the available install actions. After you
install an add-on, MATLAB manages the MATLAB path for you. This lets you start using it without
adjusting your desktop environment.
For some add-ons, you also can download the files from the Add-on Explorer without installing them.
This is useful if you want to install the add-on on a system without an internet connection. To
download the add-on without installing, select Install > Download Only.
• The add-on is not available for installation through the Add-On Explorer, for example, if you create
a custom add-on yourself or receive one from someone else.
• You downloaded the add-on from the Add-On Explorer without installing it.
• You downloaded the add-on from the File Exchange at MATLAB Central™.
Valid add-on installation files include .mltbx files (for toolboxes), .mlappinstall files (for apps),
and .mlpkginstall files (for hardware support packages). To install an add-on from one of these
files, in the MATLAB Current Folder browser, double-click the file. An installer opens to guide you
through the installation process.
Note Make sure to double-click the installation file in the MATLAB Current Folder browser. Double-
clicking to install the add-on from the system file browser is not supported on all operating systems.
You also can install some add-ons programmatically. For more information, see
matlab.addons.install.
The install location of an add-on depends on its type. MATLAB installs MathWorks products in the
matlabroot folder and hardware support packages in the folder returned by
matlabshared.supportpkg.getSupportPackageRoot. For more information about a specific
support package install location, see the documentation for the package.
MATLAB installs all other add-ons in a default installation folder specific to the platform.
To change the default installation folder, on the Home tab, in the Environment section, click
Preferences > MATLAB > Add-Ons. Then, in the Installation Folder field, specify a folder name
to which you have write access.
8-3
8 Add-Ons
If you change the default installation folder, add-ons installed in the previously selected folder are no
longer accessible from within MATLAB. Changing the default installation folder or customizing
installed add-ons is not supported in MATLAB Online.
Manage Add-Ons
To view and manage installed add-ons, go to the Home tab and select Add-Ons > Manage Add-
Ons. The Add-On Manager displays all add-ons that are installed in the add-ons installation folder, as
well as MATLAB products and hardware support packages.
To manage an individual add-on, click the Options button to the right of the add-on and select from
the available actions:
• Open Folder
• Open Documentation
• View in Add-on Explorer
• View Getting Started Guide
• Setup
• Version
• Enabled
• Uninstall
To customize your MATLAB environment, use the Enabled action to enable and disable add-ons. You
also can enable or disable add-ons using the matlab.addons.enableAddon and
matlab.addons.disableAddon functions.
If an add-on has multiple versions installed, only one version can be enabled. To view the currently
enabled version, select Version. MATLAB displays a check mark next to the currently enabled
version. To enable a different version, click it. For more information about installing multiple versions
of an add-on, see matlab.addons.install.
Update Add-Ons
You can update installed add-ons as well as your current installed version of MATLAB using the Add-
On Manager. On the Home tab, click Help > Check for Updates. The Add-On Manager opens with
the Updates tab selected. View and install any available updates.
Run Apps
An app is a self-contained MATLAB program with a user interface. To view and interact with the user
interface after installing the app, run it. Go to the Apps tab and expand the apps gallery by clicking
the down arrow on the far right. Then, navigate to your installed app and click the icon. Custom
apps that you write or receive from someone else appear in the My Apps section. You can run
multiple custom apps concurrently, including multiple instances of the same app.
8-4
Get and Manage Add-Ons
See Also
matlab.addons.install | matlab.addons.installedAddons |
matlab.addons.isAddonEnabled | matlab.addons.enableAddon
Related Examples
• “Package Apps From the MATLAB Toolstrip”
• “Create and Share Toolboxes”
8-5
8 Add-Ons
• MATLAB Coder™
• Stateflow®
• Simulink Coder
• Embedded Coder®
• Simulink Test™
• C2000™ Microcontroller Blockset — See “Hardware Setup for C2000 Microcontroller Blockset”
(C2000 Microcontroller Blockset).
See Also
Related Examples
• “Get and Manage Add-Ons” on page 8-2
• Supported and Compatible Compilers
8-6
9
Internationalization
In this section...
“Default Locale Setting” on page 9-2
“Supported Character Sets and Encodings” on page 9-2
“Platform-Specific Localized Formats for Current Folder Browser” on page 9-3
The locale setting defines the language of your user interface and the display formats for information
like time, date, and currency. MATLAB uses the user-specified locale on all platforms.
If MATLAB does not correctly display characters in your language, you might have a locale setting
problem. Locale is composed of individual settings that you can control. Each platform uses different
parameters to specify the locale setting. These terms are relevant to understanding locale settings:
For example, for the U.S. English locale setting en_US.UTF-8, en means that the display
language is English. US indicates that time and date displays use U.S. conventions. UTF-8 is the
character encoding (codeset) used to display text.
• ASCII (American Standard Code for Information Interchange) — Nearly universal character
encoding for US English and control characters.
• Unicode — A universal character set that “provides a unique number for every character, no
matter what the platform, no matter what the program, no matter what the language.”
• UTF-8 — A variable width character encoding tor Unicode that is backwards compatible with
ASCII. It has become the dominate encoding for the World Wide Web and anywhere else that
cross-platform, cross-locale interoperability is required.
• user locale setting — Setting on your computer that specifies the locale that you want to use when
running MATLAB. If your user-specified locale is not supported, MATLAB uses the default locale
en_US_POSIX.US-ASCII.
• system locale setting — Setting on Microsoft Windows platforms. The user locale and system
locale must be the same value. If these values are not the same, you might see garbled text or
incorrectly displayed characters.
• i18n — Short for the word internationalization, where 18 stands for the number of letters
between the letters i and n.
9-2
Locale Setting Concepts for Internationalization
See Also
Related Examples
• “Set Locale on Microsoft Windows Platforms” on page 9-5
• “Set Locale on macOS Platforms” on page 9-7
• “Set Locale on Linux Platforms” on page 9-8
9-3
9 Internationalization
• MATLAB C/C++ and Fortran engine library functions and the loadlibrary function cannot find
files located in folder names that contain non 7-bit ASCII characters.
• MATLAB C/C++ and Fortran engine library functions and the calllib function used to call C
library functions cannot convert Unicode®-compatible input arguments of type char* to MATLAB
character arrays.
• The matlab.wsdl.createWSDLClient function cannot read non 7-bit ASCII characters in Web
Services Description Language (WSDL) documents.
When you have a file containing text that has characters in a different encoding than that of your
platform, when you save or publish your file, MATLAB displays those characters as garbled text.
9-4
Set Locale on Microsoft Windows Platforms
MATLAB does not support every locale setting. If your locale is not supported, MATLAB uses the
default locale en_US_POSIX.US-ASCII, also known as C locale.
When you change the system locale, restart your system. Otherwise, you might see unexpected
behaviors.
As of Windows 10 1803, Microsoft added the ability to specify UTF-8 as the character encoding used
by Windows itself. This feature can be enabled using the instructions shown above, however, after
step 6, select the check box next to Use Unicode UTF-8 for worldwide language support. If this
setting is enabled, MATLAB uses UTF-8 as both its default and its locale-specific character encoding.
Note It is not necessary to enable this option in order to use UTF-8 with MATLAB. MATLAB uses
UTF-8 as the default encoding independent of this setting. Therefore, most users do not need to
enable this Windows option; however, MATLAB works correctly if it is enabled.
1 Select Start > Control Panel > Clock, Language, and Region > Region and Language.
2 Open the Formats tab.
3 Select a target locale from the Format drop-down list.
9-5
9 Internationalization
System Locale
1 Select Start > Control Panel > Clock, Language, and Region > Region and Language.
2 Open Administrative tab.
3 In the Language for non-Unicode programs section, click Change system locale....
4 Select a target locale from the Current system locale drop-down list.
5 Restart the system.
9-6
Set Locale on macOS Platforms
If you customize the locale setting, MATLAB ignores the customized portion. MATLAB ignores the
LANG environment variable and the Terminal application locale setting.
MATLAB does not support every locale setting. If your locale is not supported, MATLAB uses the
default locale en_US_POSIX.US-ASCII, also known as C locale.
9-7
9 Internationalization
MATLAB does not support every locale setting. If your locale is not supported, MATLAB uses the
default locale en_US_POSIX.US-ASCII, also known as C locale.
See Also
More About
• “Numbers Display Period for Decimal Point” on page 9-12
9-8
Unexpected Behavior on macOS Platforms
MATLAB ignores the LANG environment variable and the Terminal application locale setting.
See Also
Related Examples
• “Set Locale on macOS Platforms” on page 9-7
9-9
9 Internationalization
See Also
Related Examples
• “Set Locale on Microsoft Windows Platforms” on page 9-5
9-10
datenum Might Not Return Correct Value
For example, look at the modification date of your MATLAB license_agreement.txt file:
cd(matlabroot)
f = dir('license_agreement.txt')
f =
name: 'license_agreement.txt'
date: '10-May-2015 17:48:22'
bytes: 5124
isdir: 0
datenum: 7.3317e+005
If your code uses the date field of the dir command, similar to:
n = datenum(f.date);
n = f.datenum;
See Also
dir
9-11
9 Internationalization
MATLAB uses a period for a decimal point, regardless of the format specified by the user locale. For
example, the value of pi can be displayed as 3,1416 or 3.1416, depending on the format used by a
locale. MATLAB always displays 3.1416.
The MATLAB language reserves the use of commas to the cases described in the Symbol Reference
topic.
See Also
More About
• Symbol Reference: Comma
9-12
Script Compatibility
Script Compatibility
As of R2020a, plain text files, such as MATLAB scripts or functions, that are encoded using UTF-8
(note that all 7-bit ASCII files are de facto UTF-8 encoded), work seamlessly across all platforms and
all locales. Plain text files created with an earlier version of MATLAB that are not UTF-8 encoded also
work if they were created in the same locale that the current MATLAB is using. Under most
circumstances, MATLAB also operates correctly with plain text files encoded in one of the locale-
specific CJK (Chinese, Japanese, or Korean) encodings.
9-13
9 Internationalization
1 On the Home tab, in the Environment section, click Preferences and select MATLAB >
General.
2 Select an option for the Desktop language preference. If the Desktop language preference is
not displayed, then this preference is not supported for your current system configuration.
3 Restart MATLAB for the preference change to take effect.
Most desktop elements and apps use the language specified by the Desktop language preference.
However, system dialog boxes, such as file selectors or color pickers, use the operating system
display language.
9-14
Change the MATLAB Desktop Language
See Also
Preferences
More About
• “Translated Documentation” on page 4-13
• “Locale Setting Concepts for Internationalization” on page 9-2
9-15
9 Internationalization
Suppose you are using a Linux based computer with a German keyboard. Without the XKEYBOARD
extension, Simulink uses the default layout, which is English, and can therefore produce incorrect
characters. MATLAB correctly recognizes the keyboard as German.
If you encounter this issue, try enabling the XKEYBOARD extension, or use an X server that supports
this extension.
9-16
10
MATLAB Online
10 MATLAB Online
When you upload a file to MATLAB Online, it is added to your MATLAB Drive. If you add files to your
MATLAB Drive outside of MATLAB Online, you can access those files in MATLAB Online. For more
information about adding files to MATLAB Drive, see “Add Files to MATLAB Drive” on page 12-9.
To download a file from MATLAB Online to your local system, in the Files browser, right-click the file
and select Download.
Preview Files
To preview the contents of a file or folder in MATLAB Online without opening it, in the Files browser,
right-click the file and select Preview. You also can click the Preview button to the right of the file
or folder name.
Restore Files
In MATLAB Online, each time you save a code file, MATLAB stores the contents of your file in the
version history. To recover a previous version of a file, select the File Versions tab.
10-2
Access Files in MATLAB Online
Browse for the version you want by selecting from the list, or by clicking Older or Newer. When you
find the version, click Restore as latest. MATLAB adds the restored file version to the top of your file
version history with a new timestamp and version number.
Note MATLAB Online stores previous versions of a file for 30 days. After 30 days, the previous
version of the file is permanently deleted.
See Also
Related Examples
• “Manage Files and Folders” on page 6-34
• “MATLAB Online”
10-3
11
Cloud Storage
11 Cloud Storage
After creating the links, share them by distributing them to others directly, or by creating Open in
MATLAB Online buttons and including them in a Git README file.
Create Links
You can create links interactively or manually.
Interactively
Manually
To create the link manually, copy the link template below. Then, replace the template parameters with
the information for the repository, as described in the table below.
matlab.mathworks.com/open/github/v1?repo=<authorname>/<reponame>&file=<filename>&project=<projectname>&line=<linenumber>
To omit optional parameters, omit the parameter name and value, as well as the & character that
precedes them. For example, this link template omits the project parameter.
matlab.mathworks.com/open/github/v1?repo=<authorname>/<reponame>&file=<filename>&line=<linenumber>
Note Concurrent access of a Git repository in cloud storage might corrupt the repository.
Share Links
After you create a link, you can distribute it to others, for example, by including it in an email. You
also can share the link by creating an Open in MATLAB Online button and including it in a Git
README file. To create the button, copy the markdown template below, replacing the link parameter
with the link that you created to open the repository in MATLAB Online.
[](<link>)
When you add the markdown to a Git README file, the file shows an Open in MATLAB Online
button, as shown below.
11-2
Open in MATLAB Online from GitHub
See Also
Related Examples
• Create Links for MATLAB Online
• “MATLAB Online”
• “Use Git in MATLAB”
• “Clone Remote Git Repository into New Project”
• “Set Source Control Preferences”
11-3
12
MATLAB Drive
Install Instructions
To install MATLAB Drive Connector, follow these steps:
• From within MATLAB — Click the MATLAB Drive button to start the installer.
If you do not see the MATLAB Drive button in the Current Folder toolbar, right-click the
toolbar and select Customize. Then, in the MATLAB Toolbar Preferences Controls section,
select the check box for the MATLAB Drive control and select OK. MATLAB adds the button
to the toolbar.
• From the web — Go to the Connector download page and select Install for Windows, Install
for Mac, or Install for Linux. Installing from the web does not require you to have MATLAB
installed.
2 Configure the location of your MATLAB Drive folder and your MATLAB Drive settings.
Note When setting the location of your MATLAB Drive folder, these locations are not supported:
If you set the location of your MATLAB Drive folder to a folder that is already being synced,
the files in your MATLAB Drive folder might not correctly sync with the files on the cloud.
3 Click Finish to complete setup and synchronize your MATLAB Drive files between your
computers and online accounts. To change any of your selections, click Back.
When the installer finishes, MATLAB Drive is ready for use on this computer. See “Access Files in
Your MATLAB Drive” on page 12-6 for instructions on accessing MATLAB Drive.
Uninstall Instructions
Operating Instructions
System
Windows 1 Exit MATLAB Drive Connector.
2 Go to the Control Panel, and select Programs > Uninstall a program.
3 (Optional) If you are on a shared computer, clear your cached account information by
deleting the ServiceHost folder. The default location for this folder is C:\Users
\username\AppData\Local\MathWorks\ServiceHost.
12-2
Install MATLAB Drive Connector
Operating Instructions
System
macOS 1 Exit MATLAB Drive Connector.
2 Open a Terminal window.
3 Navigate to the MATLAB Drive Connector installation folder:
cd ~/Library/Application Support/MathWorks/ServiceHost
4 Run the uninstaller:
./v<VERSION>/mci/InstallMathWorksServiceHost.app/Contents/bin/maci64/UninstallMathWorksServiceHost
VERSION is the MATLAB Drive Connector version, which you can find under Settings
in the Connector; for example, 1.8.0.8.
5 (Optional) If you are on a shared computer, clear your cached account information by
deleting the ServiceHost folder. The default location for this folder is ~/Library/
Application Support/MathWorks/ServiceHost.
Linux 1 Exit MATLAB Drive Connector.
2 Open a Terminal window.
3 Navigate to the MATLAB Drive Connector installation folder:
cd ~/.MathWorks/ServiceHost/<HOSTNAME>
./v<VERSION>/mci/bin/glnxa64/UninstallMathWorksServiceHost.sh
VERSION is the MATLAB Drive Connector version, which you can find under Settings
in the Connector; for example, 1.8.0.8.
5 (Optional) If you are on a shared computer, clear your cached account information by
deleting the ~/.MathWorks/ServiceHost/<HOSTNAME> folder.
See Also
Related Examples
• “MATLAB Drive Preferences and Account Information” on page 12-4
• “Access Files in Your MATLAB Drive” on page 12-6
12-3
12 MATLAB Drive
Preferences
To set preferences for MATLAB Drive:
•
Windows — Click the MATLAB Drive Connector icon in the Windows system notification
area.
•
macOS — Click the MATLAB Drive Connector icon in the MAC OS X Dock.
2
Click the Show MATLAB Drive actions button , and select Preferences.
3 Select a tab and adjust the options as described in the following table.
Tab Preference
General Select Start MATLAB Drive Connector at system startup to have
Settings MATLAB Drive Connector start whenever you restart your computer.
Select Help improve MATLAB Drive Connector to send your experience
information to MathWorks.
MATLAB Folder Location for MATLAB Drive. This location is specified during the
Drive installation of MATLAB Drive Connector and cannot be changed once it is set.
Select a Show notifications option to specify what notifications MATLAB
Drive Connector should display. Options include:
• All — Display all notifications in the Windows system tray or on the macOS
menu bar. For less interruption to your work, notifications are aggregated
and shown less often.
• Recommended — Display notifications for errors and conflicts only.
• Off — Display no notifications for any sync activity.
MathWorks Your Name and E-mail address.
Account
Changing your name and email address is not supported in the MATLAB Drive
Connector preferences. To change your name and email address, edit your
MathWorks Account profile on mathworks.com.
Storage Quota
The amount of space you have on MATLAB Drive is limited by the storage quota. Anyone with a
MathWorks Account has a 5 GB storage quota. If you have an eligible MATLAB license that is current
on Software Maintenance Service, your storage quota increases to 20 GB. For more information, see
How much storage do I have in MATLAB Drive?.
For all accounts, when you exceed your storage quota, you cannot perform the following tasks on
MATLAB Drive:
• Save files
12-4
MATLAB Drive Preferences and Account Information
If you run out of storage space, delete files to create space. Items in Deleted Files do not count
toward this quota. If you want to restore an item from Deleted Files, you must have the available
storage space.
Deleted Files has its own quota that is equal in size to your MATLAB Drive quota. If your Deleted
Files exceeds this quota, the oldest items are deleted automatically to reduce the storage amount.
This deletion is permanent.
Note If your Software Maintenance Service has lapsed and you remain over storage quota for 12
months, MathWorks reserves the right to delete some files. Additionally, if your account has been
inactive for 24 months and you are not under Software Maintenance Service, MathWorks reserves the
right to delete all your files. MathWorks may also delete files if you are in violation of the SLA or
federal or local laws. In any case, the deletion affects only the files stored in MathWorks cloud.
Your account is considered inactive if you have not signed into any MathWorks applications that use
MATLAB Drive. These applications include, but are not limited to: MATLAB Online, MATLAB
Mobile™, MATLAB Drive Connector, and MATLAB Drive online.
See Also
Related Examples
• “View MATLAB Drive Connector Status and Notifications” on page 12-25
12-5
12 MATLAB Drive
MATLAB Drive operates like any other folder, with the significant advantage that files can be synced
with any other MATLAB Drive folder, such as in MATLAB Drive online or on another computer that
uses MATLAB Drive Connector.
This table describes several actions that you can take on your files and folders in MATLAB Drive
online.
Action Instructions
Preview a file or folder You can preview files including MATLAB code files, text files,
image files, and audio files.
If the file you want to preview is too large or has a file type that is
not supported for previewing online, MATLAB Drive online
prompts you to download the file.
Open a file You can open and edit files in MATLAB Online.
12-6
Access Files in Your MATLAB Drive
Action Instructions
Download a file or folder To download a file or folder from MATLAB Drive online to your
desktop, select the file or folder and then click Download.
MATLAB Drive online saves the file or folder in your system's
default downloads folder. To download multiple files at once, select
the files that you want to download and then click Download.
Downloading multiple folders or a combination of files and folders
at once is not supported.
12-7
12 MATLAB Drive
Location Instructions
System file browser In your system file browser, select the MATLAB Drive folder.
MATLAB In the Current Folder browser, select the MATLAB Drive folder.
You also can click the MATLAB Drive button on the Current
Folder toolbar. Clicking the MATLAB Drive button in the Current
Folder toolbar also starts MATLAB Drive Connector if it is installed
but not running.
When you edit a file in the MATLAB Drive folder, you are editing a local copy of the file. MATLAB
Drive updates the files in the cloud with the changes you make locally. Because MATLAB Drive stores
a local copy of files on each computer that has MATLAB Drive Connector installed, you can access
these files when offline or when syncing is paused. File syncing resumes when MATLAB Drive
Connector is running and an internet connection is available, or when syncing is resumed.
See Also
Related Examples
• “Add Files to MATLAB Drive” on page 12-9
• “Share Folders Using MATLAB Drive” on page 12-11
• “Install MATLAB Drive Connector” on page 12-2
12-8
Add Files to MATLAB Drive
• You can add files created or updated while you are working in MATLAB by setting the Current
Folder browser to your MATLAB Drive.
• You can add files created or updated while you are working in MATLAB Online or MATLAB Mobile
to your MATLAB Drive.
If you have MATLAB Drive Connector installed, files on your local MATLAB Drive and MATLAB Drive
online are automatically synced when the Connector is running. The Connector displays the files that
have been synced under Activity. Updates of files greater than 250 MB can take longer to update.
If you do not have the MATLAB Drive Connector installed, you can add folders and files to your
MATLAB Drive using MATLAB Drive online with the Upload button (select Files or Folder) or by
dragging and dropping folders and files from the operating system file browser. For either method,
empty folders are not uploaded.
Note
Sync Exclusions
Some small system files, temporary files, and folders created by applications are excluded from
syncing. This exclusion includes the following files:
• desktop.ini
• thumbs.db
• .DS_Store
• Icon\r
Also excluded from syncing are items named in any of the following ways:
• File name begins with ~$ (a tilde and a dollar sign), .~ (a dot and a tilde), or ._ (a dot and an
underscore)
• File names that end with ~ (a tilde)
• File names starting with ~ (a tilde) and ending with the extension .tmp.
• Files with the extension .asv, .autosave, or .mlx.bak
• Folders called slproj
12-9
12 MATLAB Drive
See Also
Related Examples
• “Access Files in Your MATLAB Drive” on page 12-6
• “Restore Deleted Files in MATLAB Drive Online” on page 12-21
• “Manage File Conflicts and Update Issues in MATLAB Drive” on page 12-22
12-10
Share Folders Using MATLAB Drive
When you send someone a personal invitation to a shared folder, they can preview it and add it to
their files. They can also edit its contents if you grant them permission to do so. When you send
someone a view-only link, they can preview it and add it to their files, but not edit it. Previewing and
adding shared folders to your files can only be done in MATLAB Drive online and requires a
MathWorks Account.
To share a folder from MATLAB, you must be running MATLAB R2019b or later, MATLAB Drive
Connector must be running, and the folder you choose to share must be in your MATLAB Drive. If you
are working in MATLAB Online, you do not need MATLAB Drive Connector to share folders since
sharing is always enabled.
1 Right-click the folder and select Share > Invite Members. If you have already shared the folder
by personal invitation, select Manage Members instead. In MATLAB Drive online, you also can
click the Share button and select from the available options.
In MATLAB Online, you also can select the Preview button to the right of the folder, and in the
Share section, select from the available options.
2 In the Invite section of the invitation, enter the email addresses of the people that you want to
share this folder with. To share the folder with multiple people, enter multiple email addresses
and separate them with semicolons or commas.
3 Select Can View to share the folder as a read-only folder or Can Edit to allow invited members
to edit its contents. If you want to share the folder with multiple people using different
permissions, send each invitation separately.
4 Optionally, enter a message to include with the invitation.
5 Click Send. MATLAB Drive sends an email to the people you have invited.
12-11
12 MATLAB Drive
Once you personally invite someone to share a folder, you can change their folder permissions from
MATLAB and MATLAB Drive online. For example, if you invite someone to share a folder as a read-
only folder, you can change their permissions to allow them to edit its contents.
To change the folder permissions for an invited member, right-click the shared folder and select
Share > Manage Members. In the Shared With section, next to the address of the invited member,
select a different folder permission. Then, click Save to update the permissions.
In MATLAB Drive online, you also can click the Share button and select Manage Members. In
MATLAB Online, you also can select the Preview button to the right of the folder, and in the Share
section, select Manage Members.
12-12
Share Folders Using MATLAB Drive
Once you personally invite someone to share a folder, you can revoke their access.
To revoke access, right-click the shared folder and select Share > Manage Members. Click the X
next to the name of the member to revoke shared access.
In MATLAB Drive online, you also can click the Share button and select Manage Members. In
MATLAB Online, you also can select the Preview button to the right of the folder, and in the Share
section, select Manage Members.
In MATLAB Online, you also can select the Preview button to the right of the folder, and in the
Share section, select from the available options.
12-13
12 MATLAB Drive
To remove access to a shared folder from a view-only link, right-click the shared folder and select
Share > Manage Link. Click Delete Link and confirm the deletion by clicking Delete.
In MATLAB Drive online, you also can click the Share button and select Manage Link. In MATLAB
Online, you also can select the Preview button to the right of the folder, and in the Share section,
select Manage Link.
Members who gained access to the folder using the link will no longer have access to it, and anyone
who tries to use the link in the future gets an error. Deleting the link does not cause any change in
access to those who received a personal invitation to the shared folder. To change their access, see
“Change Member Permission” on page 12-12.
12-14
Share Folders Using MATLAB Drive
When you are personally invited to a shared folder, you receive an email with a link to the invitation.
Click View Folder in the invitation to open the pending invitation in MATLAB Drive online.
To view all of your pending invitations in MATLAB Drive online, click Shared Content on the left side
of the page.
When the invitation opens, MATLAB Drive online displays a preview of the shared folder. You can
navigate the structure of the shared folder and preview individual files. You must be logged in with
your MathWorks account to preview the folder. To view and open the contents of the folder, and to
edit them if permitted, add the folder to your files.
When you receive a view-only link to a shared folder, open the link to preview it in MATLAB Drive
online. When the preview opens, you can navigate the structure of the folder and preview individual
files. Previewing a folder shared by link does not require a MathWorks account. To view and open the
contents of the folder, add it to your files.
12-15
12 MATLAB Drive
You can also forward the link to others. To get a new copy of the link, click Share Link. In the
Share by Link dialog box, click Copy Link to copy the link to the clipboard.
To view and open the contents of a folder shared with you, and to edit them if permitted, add the
folder to your files. You can add a folder to your files either by creating a shortcut to the shared
folder, or by creating a copy of the shared folder that is only visible and accessible to you.
To create a shortcut to the shared folder, in the MATLAB Drive online folder preview, click the Add
to my Files button and select Add Shortcut. To create a copy of the shared folder that is only visible
and accessible to you, click the Add to my Files button and select Copy Folder. MATLAB Drive
adds the folder to your files and opens the Files view. You must be logged in with your MathWorks
account to add a shared folder to your files.
If you have MATLAB Drive Connector installed, the Connector syncs the contents of the added shared
folder to your local drive.
MATLAB Online and MATLAB Drive online indicate shared folders using the shared folder icon . If
you have MATLAB Drive Connector installed, the Connector indicates shared files in the Activity
12-16
Share Folders Using MATLAB Drive
section by displaying SHARED below the file name. If you do not have edit permissions for the
shared file, the Connector displays a padlock icon .
If you have edit permissions to a shared folder, you can edit the contents of the files and folders
within that folder. You can edit the files in MATLAB Online, or, if you have MATLAB Drive Connector
installed, you can edit the files on your local drive. As you and other members of the folder make
changes, the Connector keeps the shared folder on your local drive up-to-date.
Warning It is possible that other participants with edit permissions are also editing the same files as
you are. If this occurs, the most recently saved copy overwrites any other saved copies.
You cannot edit a shared file if you do not have edit permissions for the shared folder. If you do not
have edit permissions for a shared file, MATLAB Drive Connector displays a padlock icon below
the file name in the Activity section.
You can move a shared folder to a new location within your MATLAB Drive. If you have edit
permissions to a shared folder, you also can move or rename its contents. You can move or rename
the folder in MATLAB Drive online and, if you have edit permissions to the folder, from MATLAB.
If you have edit permissions for a shared folder, you can move or rename content inside it. When you
move or rename content inside a shared folder, the moved or renamed content is moved or renamed
for all members of the folder.
12-17
12 MATLAB Drive
Note If you move one shared folder into another, the one that you move takes on the permissions of
its new parent. For example, if a member can edit the parent folder, they can now edit the folder that
you move into it.
You can delete a shared folder in your MATLAB Drive. If you have edit permissions to a shared folder,
you can also can delete its contents. You can delete the folder from MATLAB Drive online and, if you
have edit permissions to the folder, from MATLAB.
• MATLAB Drive deletes the folder and its contents only from your MATLAB Drive.
• All others with access to the folder, whether by personal invitation or view-only link, continue to
have access to it.
• The folder no longer counts towards your storage quota.
If you have edit permissions for a shared folder, you can delete content inside it. When you delete
content inside a shared folder:
• MATLAB Drive deletes the content from your MATLAB Drive and for all other members of the
folder.
• The content no longer counts towards your storage quota.
When you delete a shared folder or its contents, MATLAB Drive moves the deleted items to your
Deleted Files folder. You then can choose to permanently delete those items from your MATLAB
Drive.
Note MATLAB Drive permanently deletes content (including shared folders) in your Deleted Files
folder after 30 days or if your Deleted Files folder is over the deleted files storage quota.
If you permanently delete a shared folder from your Deleted Files folder:
• The folder and its contents are permanently deleted only from your MATLAB Drive.
• All others with access to the folder continue to have access to it.
• If you are the owner of the shared folder, then the folder becomes ownerless. When a folder is
ownerless, no new members can gain access to the folder, whether by personal invitation or view-
only link. In addition, MATLAB Drive deletes all pending invitations to access the folder.
• The content is permanently deleted from your MATLAB Drive and for all members of the folder.
You cannot permanently delete content from a shared folder that has active members with edit
permissions to the folder.
12-18
Share Folders Using MATLAB Drive
Sharing Limitations
There are limits on how many folders you can share, how many people you can share each folder
with, and how much data your MATLAB Drive can hold.
You can have up to 100 shared folders in your MATLAB Drive. This total includes folders shared by
you (regardless of whether others have accepted your invitation) and folders shared by others that
you have added to your files. Sub-folders in shared folders are not included in this limit.
The number of people that you can share a folder with depends on whether you have an eligible
MATLAB license that is current on Software Maintenance Service.
• You can share a folder with 1,000 people using a view-only link and with an additional 100 people
using a personal invitation.
• You can share a folder with 10 people using a view-only link and with an additional 10 people
using a personal invitation.
After you have reached your limit for personal invitations you cannot invite others to share that
folder. If a member leaves the shared folder or declines the invitation to access the shared folder,
then you can send additional invitations.
When sharing a folder using a view-only link, when the number of people accessing the link reaches
the folder maximum, others who try to use that link cannot access the folder.
When you add a shared folder to your files, the content of that shared folder is included as part of
your total storage allotment, regardless of whether you have edit or read-only permissions to the
folder. If a member of the folder adds or deletes content, your storage allotment updates accordingly.
• Others with edit permissions can add content to your shared folders, but you cannot.
• You cannot add additional folders to your files or create new invitations or shared links to a folder.
12-19
12 MATLAB Drive
See Also
Related Examples
• “Access Files in Your MATLAB Drive” on page 12-6
• “Add Files to MATLAB Drive” on page 12-9
• “Restore Deleted Files in MATLAB Drive Online” on page 12-21
• “Manage Files and Folders” on page 6-34
12-20
Restore Deleted Files in MATLAB Drive Online
To restore content, select the file or folder in Deleted Files, and click Restore.
You can restore content in the Deleted Files folder under the following conditions:
• The file or folder to restore has been in the Deleted Files folder for less than 30 days. (After 30
days or if your Deleted Files has gone over storage quota, content is permanently deleted.)
• You did not permanently delete the content from the Deleted Files folder.
• You have the available storage space in your MATLAB Drive for the restored content.
• You restore an exact item that you deleted. For example, if you deleted an entire folder, you cannot
restore only a single file from that folder — you must restore the entire folder.
Items restored from the Deleted Files folder are returned to their original folder locations.
See Also
Related Examples
• “Add Files to MATLAB Drive” on page 12-9
• “Access Files in Your MATLAB Drive” on page 12-6
12-21
12 MATLAB Drive
When you restart the Connector, MATLAB Drive compares the edited file with the same file in cloud
storage. If the content is different, MATLAB Drive renames the local version of the file. The name of
the copied file has the following text appended to the file name:
conflict_copy_machinename_date
To resolve the conflict, compare the two versions, and decide which one to you want to keep. You can
merge the changes manually, or delete the version of the file you do not want. If you decide to keep
both versions of the file, you can remove the alert icon by clicking Dismiss alert from the file context
menu.
Issue Description
A file is larger than 5 GB. Updates of smaller files continue.
You exceed your MATLAB Drive Updates stop. Remove files from your MATLAB Drive to free up
quota. space.
Connection to MATLAB Drive is Updates stop until the connection is restored.
interrupted.
File name contains unsupported Updates of other files continue. Rename files that have names
characters. with unsupported characters. Follow the requirements for your
operating system when naming files.
You do not have permissions to Updates cannot proceed. You are logged in to the computer as a
access files in the MATLAB Drive user who does not have permissions to access the local
folder. MATLAB Drive folder. Log in as a user who has permissions to
access the folder, or change the permissions on the folder.
See Also
Related Examples
• “Add Files to MATLAB Drive” on page 12-9
12-22
Start and Stop MATLAB Drive Connector
From within MATLAB, in the Current Folder toolbar, click the MATLAB Drive button . This starts
the Connector.
If you do not see the MATLAB Drive button in the Current Folder toolbar, right-click the toolbar
and select Customize. Then, in the MATLAB Toolbar Preferences Controls section, select the check
box for the MATLAB Drive control and select OK. MATLAB adds the button to the toolbar.
• Windows – In the Start menu, select MATLAB Drive Connector. If you see a security alert when
you start MATLAB Drive Connector, select Allow access to continue.
• macOS – Navigate to ~/Applications in Finder, and select MATLAB Drive Connector.
• Linux – Execute ~/bin/MATLABConnector start in a terminal window.
To pause syncing, open MATLAB Drive Connector. In the top-right corner of the window, click the
Show MATLAB Drive actions button and select Pause syncing.
To resume syncing, click Resume syncing. You also can click the Show MATLAB Drive actions button
, and select Resume syncing.
12-23
12 MATLAB Drive
To stop MATLAB Drive Connector, open the Connector and in the top-right corner of the window, click
the Show MATLAB Drive actions button and select Quit. On Windows, you also can right-click the
MATLAB Drive Connector icon in the Windows system notification area and select Exit. On Linux, you
also can execute ~/bin/MATLABConnector stop in a terminal window.
See Also
Related Examples
• “Install MATLAB Drive Connector” on page 12-2
• “Access Files in Your MATLAB Drive” on page 12-6
12-24
View MATLAB Drive Connector Status and Notifications
MATLAB Drive Connector could not connect to the network. File syncing is
paused.
On Windows and macOS systems, if notifications are enabled, MATLAB Drive displays them in the
Windows system notification area or macOS dock.
See Also
Related Examples
• “Manage File Conflicts and Update Issues in MATLAB Drive” on page 12-22
• “Start and Stop MATLAB Drive Connector” on page 12-23
12-25
13
Post-Installation Tasks
13 Post-Installation Tasks
While you are not required to modify this configuration, the startup accelerator works best if you
coordinate when it runs with your particular MATLAB usage patterns. For example, by default, the
startup accelerator runs at 8:00 a.m. and again at 1:00 p.m. every day, or whenever you log on to
your computer. To take full advantage of the startup accelerator, schedule it to run at a time just
before you typically start MATLAB.
To modify this configuration, use the Windows Task Scheduler. In the Windows Task Scheduler, these
start times are called triggers. You can modify these triggers to customize when the startup
accelerator runs. You can also add triggers, delete triggers, or delete the startup accelerator task
completely. The following section shows how to change when the startup accelerator runs using the
Windows Task Scheduler. For more information about the Task Scheduler, see Windows
documentation.
On the Windows Start menu, search for the phrase “task scheduler” and press Enter.
2 Click Task Scheduler Library in the Console tree to view scheduled tasks and double-click the
name of the startup accelerator to change the configuration.
13-2
Configure the MATLAB Startup Accelerator
3 To change when the task is scheduled to start, click the Trigger tab in the task properties dialog
box. In the list of triggers displayed, select the trigger you want to change, and click Edit.
13-3
13 Post-Installation Tasks
4 To change the time the task is scheduled to run, enter a new time and click OK.
13-4
Configure the MATLAB Startup Accelerator
13-5