Most M-files you author probably depend on other files you’ve written, or maybe they depend on specialized toolboxes that you have installed. When you want to share your finely crafted code, you’re forced to remember or figure out which files you’ll need in order to run your main file. After you’ve figured that out, you probably zip up those files and ship them off to a colleague. If you’re like me, you’ll inevitably have forgotten a file.
This all feels a little non-deterministic to me and I really like predictability (I know, I’m so boring!). Enter, the MATLAB Dependency Report. This report will show you all the files that you’re dependent on. Though it will not show dependencies on base MATLAB, as those are considered implied (your colleagues will already have those files).
You’re only a couple clicks away from exposing your dependencies. First, open the file you want to generate the dependencies for in the MATLAB Editor. Next, goto the Tools menu and select Show Dependency Report.
You’ll be given an HTML report that looks something like this:
The above dependency report was run on the Image Processing Toolbox Utilities (IMUI) submission on MATLAB Central. The report shows all of the files in the IMUI toolset that imui.m is dependent on, as well as the dependenciees on files in the Image Processing Toolbox.
You can also run the dependency report on an entire directory. In the Current Directory Browser, select the directory you want to run the report on, then select the drop-down arrow on the reports button (see below) and select Dependency Report.
Now you can be sure that you’ve included all the necessary files when you share your code – predictability at its finest!
To leave a comment, please click here to sign in to your MathWorks Account or create a new one.