Main Content

Identify Program Dependencies

If you need to know what other functions and scripts your program is dependent upon, use one of the techniques described below.

Simple Display of Program File Dependencies

For a simple display of all program files referenced by a particular function, follow these steps:

  1. Type clear functions to clear all functions from memory (see Note below).

    Note

    clear functions does not clear functions locked by mlock. If you have locked functions (which you can check using inmem) unlock them with munlock, and then repeat step 1.

  2. 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.

  3. Type inmem to 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 output:

    [mfiles, mexfiles] = inmem

Detailed Display of Program File Dependencies

For a more detailed display of dependent function information, use the matlab.codetools.requiredFilesAndProducts function. In addition to program files, matlab.codetools.requiredFilesAndProducts shows which MathWorks® products a particular function depends on. If you have a function, myFun, that calls to the 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, myFun.

{pList.Name}'
ans = 

    'MATLAB'
    'Image Processing Toolbox'

The file, myFun.m, requires both MATLAB® and the Image Processing Toolbox.

Dependencies Within a Folder

You can use the Dependency Analyzer to analyze the dependencies between all files within a folder. The Dependency Analyzer can identify these dependencies:

  • 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

To analyze the dependencies within a folder, open the Dependency Analyzer by going to the Apps tab, and under MATLAB, clicking the Dependency Analyzer icon . Then, click the Open Folder button and select the folder that you want to analyze. The Dependency Analyzer shows the results in the form of a dependency graph.

For more information about how to investigate the dependencies within the folder, see Dependency Analysis for Folders and Files.

Note

To determine which MATLAB code files someone else needs to run a particular file use the matlab.codetools.requiredFilesAndProducts function instead.

See Also

Functions

Apps

Related Topics