The search path, or path is a subset of all the folders in the file system. MATLAB® software uses the search path to efficiently locate files used with MathWorks® products. MATLAB can access all files in the folders on the search path.
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
Folders provided with MATLAB and other MathWorks products
These folders are under
matlabroot is the folder displayed
when you type
matlabroot in the Command Window.
userpath folder is a location
for storing files that MATLAB adds to the search path at startup.
You can explicitly add folders to the search path for the files you run.
Class, package, and
private folders are not on
the search path.
userpath folder is first on the
search path, above the folders supplied by MathWorks.
By default, MATLAB adds the
to the search path at startup. Therefore, the
convenient for storing files where MATLAB can access them.
userpath consists of a primary
path, and on Mac and Linux® platforms, it also contains a
secondary path. The primary path is only one folder, but the secondary
path can contain multiple folders.
The default primary
On Windows® platforms, the default primary
On Mac platforms, it is
On Linux platforms, it is
To determine the current
By default, the
userpath folder is
the startup folder when you start MATLAB by double-clicking either
the MATLAB shortcut on Windows systems, or the MATLAB application
on Mac systems.
There are several ways to determine if files and folders are on the search path.
For a file, run
If the file is on the search path, MATLAB returns the full path
to the file.
Use the Current Folder browser to determine if files or folders in the current folder are on the search path:
In the Current Folder browser, right-click any file or folder, and ensure 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.
to view 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.
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 the search path information in the
pathdef.m file is a series of full path names,
one for each folder on the search path, separated by a semicolon (
pathdef.m is in
When you change the search path, MATLAB uses it in the
current session. 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.
This updates the