Ever wanted a class dependency diagram and documentation of your MATLAB Classes. How about leveraging Doxygen to document your development project?
Fabrice provides a simple interface to make this possible. Interestingly enough, this entry doesn't actually contain MATLAB Code!
Do you want to know how MATLAB Classes are related?
The above image shows a subset of the class hierarchy for a project I have been working on, which I was able to generate using Fabrice's tool.
The diagram depicts each class in a box. The arrow points to the parent class from which each class is inherited.
The terminus for the dependency path is a built-in class in MATLAB, which in this case is "handle".
If you use comments in MATLAB Code to document your functions and classes, then you need to apply Fabrice's extra convention of "%>" instead of just "%" to determine which comments get parsed by Doxygen.
In addition Doxygen convention is the documentation for a function by default comes before the function, which the convention in MATLAB is that it comes after the function. To make sure your documentation is available in Doxygen and using the MATLAB DOC function, then you likely want to consider using the "<" flag in your first comment after a MATLAB Function or class parameter definition.
I did make a quick modification of the Perl script in Fabrice's entry to automate that process so that "%>" was replaced by "///<" and make the assumption that MATLAB Documentation always comes after the function or parameter definition.
You can use comments in your MATLAB code to generate documentation without any additional work. However it doesn't provide much in the way of developing dependency graphs.
- Do you use Doxygen to document your software development projects?
- Should this be a capability built into MATLAB or Simulink?
- What about generated C or HDL-code?
- Do you use a different method for using Doxygen with MATLAB?
Let us know here.
Get the MATLAB code
Published with MATLAB® 8.6
Comments are closed.
4 CommentsOldest to Newest
We use mtoc++ (also from the file exchange).
If you build larger frameworks in MATLAB, doxygen is a must-have. While the MATLAB documentation features are great for smaller scripts and documenting the purpose of code, things like dependency and caller graphes in doxygen are great to document the architecture of a program/framework. A native doxygen support would be great!
I also use mtoc++ which is very nice. I think it would be useful to integrate it to MATLAB for the further releases.
Interesting post which clearly highlights some of the shortfalls of MATLAB for advanced developers.
A built-in class relationship diagram tool is long overdue. It would be great to have a tool where we could easily go from UML class diagrams to MATLAB classdefs and vice versa. We currently have to do UML in a third party tool and then manually write the classdefs and hope one reflects the other.
The doc tools are also not suitable for advanced toolbox development. We have our own build scripts to auto generate more end-user friendly looking help doc and function reference pages from our classdefs. We seem to waste far too much time hacking around trying to get user-friendly documentation for our tools.
It’s a great tool, we are using it for years now !
The only problem is that we have to document our classes and our functions separately — classes with Doxygen tool and functions with a “standard” MatLab Publisher markup. It would be great if one day MatLab provides a commun tool to document the whole project.