Reputation: 915
When we write so many m-files which are all inter-related, it becomes hard to track (even for the coder himself!) which m-file calls which m-file.
If there is a program that generates a easy-to-see visualization of this relationship between m-files, it will be immensely convenient.
Is there any such thing?
Upvotes: 6
Views: 3107
Reputation: 65440
If you just want a dependency list for a given file there are a few built-in ways of doing this.
matlab.codetools.requiredfilesandproducts
- Static code analyzer for determining dependencies of your code. It breaks the result down into the different types of dependencies (built-ins, custom, mex files, etc.). This replaces depfun
.
Interactive Dependency Report - This provides an interactive front-end to the static dependency analyzer. It can run dependency checks on an entire folder or a single file.
The Built-in Profiler - If you don't want a static code analyzer and instead care about which files are actually called when you execute a given function, you can use the built-in profiler to inspect this, specifically the FunctionHistory
output field.
Personally, I find the built-in tools pretty limited and slow. The File Exchange has a number of fantastic entries for determining and graphing dependencies. Here are some that I personally have experience with:
FDEP - Very speedy and comprehensive tool for determining dependencies. It has even been featured as a Pick of the Week. This tool provides both a data structure you can use or you can use the GUI to browse through your dependencies. We use this in all of our tests to ensure that all dependencies are included with a project.
GraphVis-like tools for MATLAB - Analyzes your code and generates an input file for GraphViz which can then be used to generate a dependency tree. I have personally used this to make sense of huge projects which I have inherited.
M2HTML - This is an old one but it works well. It parses all of your code and produces an interactive website complete with source code, documentation, and dependency trees. Another huge benefit is that all pages are interactive allowing you to navigate through your source code via hyperlinks.
Upvotes: 6