Documentation

Files and Folders thatMATLABAccesses

Where DoesMATLABLook 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, typepwdin the Command Window.

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

  • Change the current folder to the folder that contains the files. Use thecdfunction 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 theuserpathMATLAB文件夹,搜索路径。来确定the location of this folder, run theuserpathfunction.

Files and Folders You Should Add to the Search Path

The MATLAB search path should include:

  • Folders containing files that you run.

  • Folders containing files that arecalled byfiles 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, seeFolders Containing Class Definitions.

If files call other files that are in multiple folders, determine the location of all the called files by creating a Dependency Report. SeeDependencies 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 doesnotuse is called ashadowedfile. In some cases, MATLAB warns you that a shadowed file exists.

Locations ofMathWorks下载188bet金宝搏

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

  • Donotstore your personal files and folders inmatlabroot/toolbox.

  • Donotchange files, folders, and subfolders inmatlabroot/toolbox. The exception is thepathdef.mfile, which you can update and save in its default location,matlabroot/toolbox/local.

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

dir(fullfile(matlabroot,'toolbox'))

See Also

||

Related Topics