View License

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video

Highlights from
Get Dependent Files

5.0 | 3 ratings Rate this file 7 Downloads (last 30 days) File Size: 4.61 KB File ID: #43370 Version: 1.0
image thumbnail

Get Dependent Files


Mark Brown (view profile)


This function returns a list of dependent files called by scripts, functions, and classDef files.

| Watch this File

File Information

This function will analyze an input file for all dependent functions. It works with scripts, functions, and classDef files. It also can return any calls to external functions, toolboxes, built-in functions, Java functions, and other unknown functions. The function was developed specifically to handle large object-oriented projects with many class definitions, packages, and associated functions.

Included are methods to find all of the parent functions that call a listed function (or class). It can optionally return a sparse matrix indicating who calls whom.

Finally, a method is provided to find all of the orphans of a folder or class package that are not called by anyone -- so called "orphans".

For use with classes, this function must be called from the parent directory of any package folders, and other folders containing potential files of interest must be on the Matlab path.

 Example usage:
    % Constructor
    D = getDependents('Main.m');

    % Return list of all dependent files
    w = D.dependentFiles

    % Return direct calls made by ProgramManager.m
    x = D.whoAreCalledBy('+myPkg\ProgramManager.m')

    % Return files that directly call Job.m
    y = D.whoCall('+myPkg\Job.m')

    % Return orphans in (or below) the +myPkg package
    z = D.findOrp('+myPkg')

    % Return orphans in (or below) the \utilities folder
    z = D.findOrp('utilities')

    % List external, toolbox, builtin, Java, and unknown calls
    [ex,tb,bi,ja,un] = D.parseCalls('javaProgram.m')

This function will recursively analyze any external functions called by the input rootFile. It does not recursively search toolbox functions, built-in functions, Java functions, or other unknown functions. It does not list other functions or methods within the same input rootFile.

getDependents.m uses undocumented features of Matlab (mtree, mtfind) which may not be available in future releases. Tested successfully with R2010a, R2011a, R2012a, and R2013a.


This file inspired Depeval Check For Dependencies.

Required Products MATLAB
MATLAB release MATLAB 7.10 (R2010a)
Other requirements Requires "Recursive Directory Listing - Enhanced RDIR" by Thomas Vanaret available on Matlab FileExchange as File ID #32226.
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (4)
03 Oct 2016 AJ Rivera

Works great but not in this scenario.

Class A has method fun() which is pure virtual.
Class B inherits Class A and implements fun().

In such scenario, getDependents() does not list Class A file as a dependency.

29 Aug 2014 Matthew

By far the most accurate and most up-to-date dependency analyzer around. Great stuff Mark.

25 Sep 2013 Scott Otterson

Works perfectly. Thanks!

05 Sep 2013 Jim Hokanson

Jim Hokanson (view profile)

Thanks for posting this. I look forward to checking it out.

Comment only

Contact us