This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.


List dependencies of function or P-file

depfun has been removed. Use matlab.codetools.requiredFilesAndProducts instead. However, matlab.codetools.requiredFilesAndProducts does not identify opaque classes, such as Java® or COM classes. There is no replacement for this functionality.


  • list = depfun(fun)
  • [list,builtins] = depfun(fun)
  • [list,builtins,classes] = depfun(fun)
  • [list,builtins,classes,prob_files] = depfun(fun)
  • [list,builtins,classes,prob_files,~,eval_text] = depfun(fun)
  • [list,builtins,classes,prob_files,~,eval_text,called_from] = depfun(fun)
  • [list,builtins,classes,prob_files,~,eval_text,called_from,opaque_classes] = depfun(fun)
  • ___ = depfun(fun1,...,funN)
  • ___ = depfun(___,option1,...,optionM)



list = depfun(fun) returns the paths of MATLAB® program files that fun requires to run, where fun is a function, a P-file, or a figure file for a user interface. The output list includes second-level functions that fun calls directly, functions that the second-level functions call, and so on. The depfun function also displays a report in the Command Window.


    • depfun does not always list all dependent files. For example, depfun does not list files hidden in callbacks or files whose names are constructed dynamically for evaluation.

    • The output list often includes extra files that are not called when the function is actually evaluated.

    • If depfun returns a parse error for any of the required functions, then the rest of the output of depfun might be incomplete. Correct the problematic files and invoke depfun again.

[list,builtins] = depfun(fun) returns the built-in functions that fun requires.

[list,builtins,classes] = depfun(fun) returns the MATLAB classes that fun requires.

[list,builtins,classes,prob_files] = depfun(fun) returns the files that depfun cannot parse, find, or access. If there are problematic files (that is, if prob_files is not empty), then the rest of the output of depfun might be incomplete. Correct the problematic files, and then invoke depfun again.

[list,builtins,classes,prob_files,~,eval_text] = depfun(fun) returns a list of files that contain calls to eval or related functions (evalin, feval, or evalc). These calls potentially use functions that are not in list.

The fifth output argument for depfun is not implemented, and returns an empty structure array. To request arguments later in the list, use the tilde symbol (~) as a placeholder. The tilde suppresses the creation of an extra, empty variable.


[list,builtins,classes,prob_files,~,eval_text,called_from] = depfun(fun) returns a cell array of indices that maps each function in list to the set of functions that call it. That is, list{called_from{k}} returns the paths to the functions that call the function in list{k}.

[list,builtins,classes,prob_files,~,eval_text,called_from,opaque_classes] = depfun(fun) returns the opaque classes that fun requires, such as Java or COM classes.

___ = depfun(fun1,...,funN) returns the functions required for multiple functions fun1,...,funN. You can request any of the outputs from the previous syntaxes.


___ = depfun(___,option1,...,optionM) modifies the output as described by the specified options. For example, specify '-toponly' to list only the functions that fun calls directly. You can precede the options with one or more function names.


collapse all

Identify the MATLAB program files that strtok.m requires to run.

fun = 'strtok.m';
list = depfun(fun);

MATLAB displays a summary report in the Command Window and stores the list of files in variable list.

List only the program files that strtok.m calls directly.

fun = 'strtok.m';
list = depfun(fun,'-toponly')
depfun report summary:(top only)
-> trace list:           2 files  (total)
                         1 files  (total arguments)
                         0 files  (arguments off MATLABPATH)
                         0 files  (argument duplicates on MATLABPATH)
Notes: 1. Use argument  '-quiet' to not print this summary.
       2. Use arguments '-print','file' to produce a full
          report in file.
       3. Use argument  '-all' to display all possible
          left hand side arguments in the report(s).

list = 


One of the functions that strtok.m depends upon is num2cell. Determine which file in the dependency list calls num2cell.

Identify the functions that strtok.m requires (list) and the files that invoke each of those functions (called_from).

fun = 'strtok.m';
    called_from] = depfun(fun);

Find the index for num2cell within the dependency list.

num2cell_path = which('num2cell');
num2cell_index = find(ismember(list,num2cell_path))
num2cell_index =

Identify the file that calls num2cell.

calls_num2cell = list{called_from{num2cell_index}}
calls_num2cell =

Input Arguments

collapse all

Function name, specified as a character vector or a cell array of character vectors.

fun must be on the MATLAB path, as determined by the which function. If the path contains any relative folders, then files in those folders also will have a relative path in the output.

Example: 'plot.m'

Example: 'plot.m','mesh.m'

Example: {'plot.m','mesh.m'}

Data Types: char | cell

Reporting option, specified as one of the following options.




Identify only the files used directly by the specified function(s), fun.


Display additional internal messages.


Display only error and warning messages, and not a summary report.


Print a full report to the specified file.


Display all outputs in the report, but return only the specified output arguments.


Include both indices and full paths in an exported report for the call or called_from list. Requires the '-print' option. This information does not appear in the Command Window report.


Replaces the called_from list with a list of functions that each file calls, as derived from the called_from list.

Example: '-print','myreport.txt'

Data Types: char

Output Arguments

collapse all

Paths to required files, returned as a cell array of character vectors.

Required MATLAB built-in functions, returned as a cell array of character vectors.

Required MATLAB classes, returned as a cell array of character vectors.

Files that depfun cannot parse or access, returned as a structure with these fields:

  • name — Path to the file

  • listindex — Index of the file in list

  • errmsg — Error message that describes the problem

  • errid — Error identifier, if present

Files that call evaluation functions, returned as a cell array of character vectors.

Indices to files that call each function in list, returned as a cell array. Each element of the cell array is a numeric array of indices that correspond to elements in list. The list and called_from outputs have the same length.

Paths to opaque classes, such as Java or COM classes, returned as a cell array of character vectors.

Introduced before R2006a

Was this topic helpful?