Files and Folders That MATLAB Accesses - MATLAB & Simulink (original) (raw)

Main Content

Where Does MATLAB Look for Files?

When you do not specify a path to a file, MATLAB® looks for the file in the current folder or on the search path. Functions in the current folder take precedence over functions with the same file name that reside anywhere on the search path. To identify the current folder, type pwd in the Command Window.

To make files accessible to MATLAB, do one of the following:

Files and Folders You Should Add to the Search Path

The MATLAB search path should include:

For files in @ (class) and + (namespace) 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

When Multiple Files Have the Same Name

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.

Locations of MathWorks Products

Files and folders for products provided by MathWorks are in matlabroot/toolbox. The files and folders under matlabroot are important to your installation. In particular:

To see a list of all toolbox folder names supplied with MathWorks products, run:

dir(fullfile(matlabroot,'toolbox'))

See Also

userpath | cd | pwd

Topics