Identify Program Dependencies - MATLAB & Simulink (original) (raw)

Main Content

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

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:

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.

See Also

Functions

Apps