Handy software for automatically documenting MATLAB code

I’ve spent a good part of the past two years writing MATLAB code for EEG analysis (some of which is freely available as the ERP Mass Univariate Toolbox) and somewhat recently stumbled across a handy software package for automatically generating documentation for a set of MATLAB functions. The software is called M2HTML (http://www.artefact.tk/software/matlab/m2html/), and, true to its name, it generates a set of interlinked HTML pages from the MATLAB M-files in a branch of directories. Specifically, you get an index page that lists all the M-files and then a page for each M-file that can contain information such as the help header for that function and a list of functions called by that M-file and functions that that M-file calls. You can see an example of this at the Chronux Toolbox’s website. In addition, M2HTML produces a dependency graph like the one below, which illustrates which functions call which other functions.

Example M2HTML dependency graph

A dependency graph of M-files produced by M2HTML. Arrows indicate which functions are called by the function that is the source of the arrow. Click on the image to see it full window.

To me, the most helpful aspect of M2HTML is that it makes clear function interdependencies. This is a huge help when I update a function, since I can clearly see what other functions might consequently need to be updated as well. It also helps when trying to make sense of the flow of processing in other people’s MATLAB software packages.

If your personal MATLAB code for a project has grown beyond a dozen or so interdependent functions or if you’re trying to wrap your head around someone else’s rat’s nest of MATLAB functions, I recommend checking it out. It should take just a few minutes to figure out and apply.

-David Groppe


~ by eeging on June 5, 2011.

One Response to “Handy software for automatically documenting MATLAB code”

  1. […] See the rest here: Handy software for automatically documenting MATLAB code « Spikes … […]

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: