File Exchange Pick of the Week

Our best user submissions

Plot Subfunctions

Posted by Richard Ruff , March 6, 2015

Richard is an Application Engineer at MathWorks focused on the Embedded Coder product for code generation, primarily in the Aerospace industry.

Richard's pick this week is plot_subfun by Christopher Pedersen.

My pick this week is the utility function plot_subfun for visualizing the subroutines in a file via a node map.

Have you ever been given a MATLAB file only to spend many hours reading through it to understand the calling structure? If so, this function can save a lot of time by providing a snapshot of the calling structure, thus allowing you to quickly see the interaction between the various subroutines. As the saying goes, a picture is worth a thousand words and this function gives you the picture from the thousand words or five thousand words or ...

The File Exchange submission includes an extensive demo script, 'demo_subfun.m', that provides very detailed examples for using plot_subfun. A basic example is shown here:


There are a number of options that allow the user to customize the results generated by plot_subfun. These options are:

  • -ends: hide functions with one parent and no kids
  • -ext: show calls to external functions in a separate list
  • -hide: hide named functions and their children
  • -kids: same as -hide, but only hides the children
  • -list: display list of all functions and their calls to command line
  • -nest: hide nested functions
  • -noplot: do not plot the figure
  • -trim: trims the output to just the visible functions
  • -unhide: hidden functions are shown in grey instead
  • -unused: also show functions that are not called
  • -unusedonly: only show functions that are not called

I find plot_subfun particularly useful when developing custom UIs in MATLAB as I can quickly see what callbacks are being used and any utility routines that are shared. In addition, it can help point out where missing connections are such as needing to call a specific routine if the user selects an option such as switching between tabs on a UI and updating the data being displayed.

While there is an option to list the extenal functions that are called, I would like to see the option to include a set of files to analyze in order to see the dependency between the functions in multiple files. For Example, I have two files mainUI.m and fillUIPanel.m, I’d like to see this syntax work:

plot_subfun({'mainUI.m', 'fillUIPanel.m'});


Give it a try and let us know what you think here or leave a comment for Christopher.

Published with MATLAB® R2015a

  • print


コメントを残すには、ここ をクリックして MathWorks アカウントにサインインするか新しい MathWorks アカウントを作成します。