If you need to know what other functions and scripts your program is dependent upon, use one of the techniques described below.
For a simple display of all program files referenced by a particular function, follow these steps:
clear all functions from memory (see Note below).
Execute the function you want to check. Note that the function arguments you choose to use in this step are important, because you can get different results when calling the same function with different arguments.
display all program files that were used when the function ran. If
you want to see what MEX-files were used as well, specify an additional
[mfiles, mexfiles] = inmem
For a more detailed display of dependent function information,
In addition to program files,
which MathWorks® products a particular function depends
on. If you have a function,
myFun, that calls to
edge function in the Image Processing Toolbox™:
[fList,pList] = matlab.codetools.requiredFilesAndProducts('myFun.m'); fList
fList = 'C:\work\myFun.m'
The only required program file, is the function file itself,
ans = 'MATLAB' 'Image Processing Toolbox'
myFun.m, requires both MATLAB® and
the Image Processing Toolbox.
The Dependency Report shows dependencies among MATLAB code files in a folder. Use this report to determine:
Which files in the folder are required by other files in the folder
If any files in the current folder will fail if you delete a file
If any called files are missing from the current folder
The report does not list:
Files in the
because every MATLAB user has those files.
Therefore, if you use a function file that shadows a built-in function file, MATLAB excludes both files from the list.
Files called from anonymous functions.
The superclass for a class file.
MATLAB does not resolve these files until run time, and therefore the Dependency Report cannot discover them.
Some method files.
The Dependency Report finds class constructors that you call
in a MATLAB file. However, any methods you execute on the resulting
object are unknown to the report. These methods can exist in the
as separate method files, or files belonging to superclass or superclasses
of a method file.
Note: MATLAB does not support creating Dependency Reports for live scripts. When creating a report for all files in a folder, any live script in the selected folder is excluded from the report.
To provide meaningful results, the Dependency Report requires the following:
The search path when you run the report is the same as when you run the files in the folder. (That is, the current folder is at the top of the search path.)
The files in the folder for which you are running the report do not change the search path or otherwise manipulate it.
The files in the folder do not load variables, or otherwise create name clashes that result in different program elements with the same name.
Do not use the Dependency Report to determine which MATLAB code
files someone else needs to run a particular file. Instead use the
Use the Current Folder pane to navigate to the folder containing the files for which you want to produce a Dependency Report.
On the Current Folder pane, click , and then select Reports > Dependency Report.
The Dependency Report opens in the MATLAB Web Browser.
If you want, select one or more options within the report, as follows:
To see a list of all MATLAB code files (children) called by each file in the folder (parent), select Show child functions.
The report indicates where each child function resides, for example, in a specified toolbox. If the report specifies that the location of a child function is unknown, it can be because:
The child function is not on the search path.
The child function is not in the current folder.
The file was moved or deleted.
To list the files that call each MATLAB code file, select Show parent functions.
The report limits the parent (calling) functions to functions in the current folder.
To include local functions in the report, select Show subfunctions. The report lists local functions directly after the main function and highlights them in gray.
Click Run Report on Current Folder.
The following image shows a Dependency Report. It indicates
chirpy.m calls two files in Signal Processing Toolbox™ and
one in Image Processing Toolbox. It also shows that
which is in the current folder.
The Dependency Report includes the following:
MATLAB File List
The list of files in the folder on which you ran the Dependency Report. Click a link in this column to open the file in the Editor.
The function or functions called by the MATLAB file.
Click a link in this column to open the MATLAB file listed
in the same row, and go to the first reference to the called function.
For instance, suppose your Dependency Report appears as shown in the
previous image. Clicking \images\images\erode.m opens
places the cursor at the first line that references
In other words, it does not open
Multiple class methods
Because the report is a static analysis, it cannot determine run-time data types and, therefore, cannot identify the particular class methods required by a file. If multiple class methods match a referenced method, the Dependency Report inserts a question mark link next to the file name. The question mark appears in the following image.
Click the question mark link to list the class methods with
the specified name that MATLAB might use. MATLAB lists almost
all the method files on the search path that match the
specified method file (in this case,
Do not be concerned if the list includes methods of classes and MATLAB built-in
functions that are unfamiliar to you.
It is not necessary for you to determine which file MATLAB will use. MATLAB determines which method to use depending on the object that the program calls at run time.