|On this page…|
MATLAB® can access files that are in the current folder or on the search path. To make files accessible to MATLAB, do one of the following:
Change the current folder to the folder that contains the files.
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.
The MATLAB search path should include:
Folders containing files that you run.
Folders containing files that are called by files you run.
Subfolders containing files that you run. Making a folder accessible does not make its subfolders accessible.
For files in @ (class) and + (package) folders, make the parent folder accessible. For details, see Organizing Classes in Folders.
If files call other files that are in multiple folders, determine the location of all the called files by creating a Dependency Report. See Dependencies Within a Folder
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.