MATLAB Function Reference |

List the dependent functions of an M-file or P-file

**Syntax**

list = depfun('file_name'); [list,builtins,classes] = depfun('file_name'); [list,builtins,classes,prob_files,prob_sym,eval_strings,... called_from,java_classes] = depfun('file_name'); [...] = depfun('file_name1','file_name2',...); [...] = depfun('fig_file_name'); [...] = depfun(...,'-toponly');

**Description**

The `depfun`

function lists all of the functions and scripts, as well as built-in functions, that a specified M-file needs to operate. This is useful for finding all of the M-files that you need to compile for a MATLAB runtime application.

```
list = depfun('file_name')
```

creates a cell array of strings containing the paths of all the files that `file_name.m`

uses. This includes the second-level files that are called directly by `file_name.m`

, as well as the third-level files that are called by the second-level files, and so on.

```
[list,builtins,classes] = depfun('file_name')
```

creates three cell arrays containing information about dependent functions. `list`

contains the paths of all the files that `file_name`

and its subordinates use. `builtins`

contains the built-in functions that `file_name`

and its subordinates use. `classes`

contains the MATLAB classes that `file_name`

and its subordinates use.

`[list,builtins,classes,prob_files,prob_sym,eval_strings,...`

creates additional cell arrays or structure arrays containing information about any problems with the

called_from,java_classes] = depfun('file_name')
`depfun`

search and about where the functions in `list`

are invoked. The additional outputs are:

`prob_files`

, which indicates which files`depfun`

was unable to parse, find, or access. Parsing problems can arise from MATLAB syntax errors.`prob_files`

is a structure array whose fields are:`name`

, which gives the names of the files`listindex`

, which tells where the files appeared in`list`

`errmsg`

, which describes the problems`prob_sym`

, which indicates which symbols`depfun`

was unable to resolve as functions or variables. It is a structure array whose fields are:`fcn_id`

, which tells where the files appeared in`list`

`name`

, which gives the names of the problematic symbols`eval_strings`

, which indicates usage of these evaluation functions:`eval`

,`evalc`

,`evalin`

,`feval`

. When preparing a runtime application, you should examine this output to determine whether an evaluation function invokes a function that does not appear in`list`

. The output`eval_strings`

is a structure array whose fields are:`fcn_name`

, which give the names of the files that use evaluation functions`lineno`

, which gives the line numbers in the files where the evaluation functions appear`called_from`

, a cell array of the same length as`list`

. This cell array is arranged so that

```
[...] = depfun('file_name1','file_name2',...)
```

performs the same operation for multiple files. The dependent functions of all files are listed together in the output arrays.

```
[...] = depfun('fig_file_name')
```

looks for dependent functions among the callback strings of the GUI elements that are defined in the `.fig`

or `.mat`

file named `fig_file_name`

.

```
[...] = depfun(...,'-toponly')
```

differs from the other syntaxes of depfun in that it examines *only* the files listed explicitly as input arguments. It does not examine the files on which they depend. In this syntax, the flag `'-toponly'`

must be the last input argument.

**Notes**

- If
`depfun`

does not find a file called`hginfo.mat`

on the path, then it creates one. This file contains information about Handle Graphics callbacks. - If your application uses toolbar items from the MATLAB default figure window, then you must include
`'FigureToolBar.fig'`

in your input to`depfun`

. - If your application uses menu items from the MATLAB default figure window, then you must include
`'FigureMenuBar.fig'`

in your input to`depfun`

. - Because many built-in Handle Graphics functions invoke
`newplot`

, the list produced by`depfun`

always includes the functions on which`newplot`

is dependent: `'`

*matlabroot*`\toolbox\matlab\graphics\newplot.m'`

`'`

*matlabroot*`\toolbox\matlab\graphics\closereq.m'`

`'`

*matlabroot*`\toolbox\matlab\graphics\gcf.m'`

`'`

*matlabroot*`\toolbox\matlab\graphics\gca.m'`

`'`

*matlabroot*`\toolbox\matlab\graphics\private\clo.m'`

`'`

*matlabroot*`\toolbox\matlab\general\@char\delete.m'`

`'`

*matlabroot*`\toolbox\matlab\lang\nargchk.m'`

`'`

*matlabroot*`\toolbox\matlab\uitools\allchild.m'`

`'`

*matlabroot*`\toolbox\matlab\ops\setdiff.m'`

`'`

*matlabroot*`\toolbox\matlab\ops\@cell\setdiff.m'`

`'`

*matlabroot*`\toolbox\matlab\iofun\filesep.m'`

`'`

*matlabroot*`\toolbox\matlab\ops\unique.m'`

`'`

*matlabroot*`\toolbox\matlab\elmat\repmat.m'`

`'`

*matlabroot*`\toolbox\matlab\datafun\sortrows.m'`

`'`

*matlabroot*`\toolbox\matlab\strfun\deblank.m'`

`'`

*matlabroot*`\toolbox\matlab\ops\@cell\unique.m'`

`'`

*matlabroot*`\toolbox\matlab\strfun\@cell\deblank.m'`

`'`

*matlabroot*`\toolbox\matlab\datafun\@cell\sort.m'`

`'`

*matlabroot*`\toolbox\matlab\strfun\cellstr.m'`

`'`

*matlabroot*`\toolbox\matlab\datatypes\iscell.m'`

`'`

*matlabroot*`\toolbox\matlab\strfun\iscellstr.m'`

`'`

*matlabroot*`\toolbox\matlab\datatypes\cellfun.dll'`

**Examples**

list = depfun('mesh'); % Files mesh.m depends on list = depfun('mesh','-toponly') % Files mesh.m depends on directly [list,builtins,classes] = depfun('

`gca`

');

**See Also**

depdir | det |