File Exchange Pick of the Week

Our best user submissions

Document Your Dependencies 4

Posted by Guest Picker,

Greg's pick this week is Using Doxygen with MATLAB by Fabrice.

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!


Classy Relationships

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

What about the documentation?

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.

Documentation is already available using MATLAB

There is already a documentation mechanism available in MATLAB already. As well as the ability to display custom documentation as part of the MATLAB Documentation system.

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.

Is this something that should be in MATLAB or Simulink?

  • 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

Tobias replied on : 1 of 4

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!

Zoltán replied on : 2 of 4

I also use mtoc++ which is very nice. I think it would be useful to integrate it to MATLAB for the further releases.

David Barry replied on : 3 of 4

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.

Alexandre Kozlov replied on : 4 of 4

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.