The MATLAB® search path, is a subset of all the folders in the file system. MATLAB uses the search path to locate files used with MathWorks® products efficiently.
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.
By default, the search path includes
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
The folders provided with MATLAB and other MathWorks products,
which are under
matlabroot is the folder displayed
when you run
the Command Window
Class, package, and
private folders should not be
specified explicitly as part of the search 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 the Search Path.
userpath folder is first on the
search path. By default, MATLAB adds the
to the search path at startup. This folder is a convenient place for
storing files that you use with MATLAB.
userpath folder is platform-specific.
Windows® platforms —
Mac platforms —
Linux® platforms —
Alternatively, to determine or change the current
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.
MATLABPATH environment variable can contain
a list of additional folders to be added to the MATLAB search
path at startup. These folders are placed after the
but ahead of the folders supplied by MathWorks. By
MATLABPATH environment variable is
not set. For more information on how to set the
variable, see Set the
MATLABPATH Environment Variable.
There are several ways to determine if files and folders are on the search path. You can either check whether an individual file or folder is on the search path, or you can view the entire search path.
To determine whether a file is on the search path, run
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:
In the Current Folder browser, right-click any file or folder, and ensure that there is a check mark next to Indicate Files Not on Path.
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.
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 the Search Path.
The search path is not the same as the system path. Furthermore, there is no explicit relationship between the MATLAB search path and the system path. However, both paths help in locating files, as follows:
MATLAB uses the search path to locate MATLAB files efficiently.
The operating system uses a system path to locate operating system files efficiently.
MATLAB saves search path information in the
This file contains a series of full path names, one for each folder
on the search path.
pathdef.m is in
When you change the search path, MATLAB uses it in the
current session, but does not update
To use the modified search path in the current and future sessions,
save the changes using
the Save button in the Set Path dialog box.