File Exchange

image thumbnail

GraphViz-like tools for MATLAB

version (16.2 KB) by Jonathan Lister
Generate a function or script file call tree and plot it in a figure.


Updated 15 May 2010

View Version History

View License

mkdotfile creates a GraphViz dot language representation of the dependencies of a function. mGraphViz plots the directed graph onto a figure. These functions are a small part of a larger project to implement a doxygen like code documentation system within MATLAB that doesn't have any external program dependencies.

Additional Acknowledgments:
Inspired by mdot of M2HTML
by Guillaume Flandin <>
(Which I can no longer find on the exchange)

Cite As

Jonathan Lister (2021). GraphViz-like tools for MATLAB (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (18)

Matthew Royal

After applying the fixes to fdep that I posted to the fdep page and the below fix for mGraphViz.m, this tool functions correctly.

***** .\DOWNLOADS\mGraphViz.m
280: 'Interpreter','none','verticalAlignment','middle');
281: patchObj=cell2mat(patchObj);
282: else
280: 'Interpreter','none','verticalAlignment','middle');
281: patchObj=vertcat(patchObj{:});
282: else


Tuomas Tikkanen

This tool is dependent on fdep, which is dependent on depfun, which was deprecated in MATLAB v2016a according to this thread:


Perfect tool to see subfunctions and their relation with the core.

Christopher Pedersen

This appears to break under R2014B. Can be fixed by replacing line 282 with:
if verLessThan('matlab','8.4.0')
patchObj=cell2mat(patchObj); %original line 282
for i=1:numel(patchObj);
p(i) = patchObj{i};
patchObj = p;

Christopher Pedersen

@James. I had the same error (on a mac).
You can replace line 134 with the following to explicitly tell matlab where to find mwdot:
foo = fullfile(matlabroot,'bin',lower(computer),matlabEngine);
[status,returnCode]=system([foo ' -Tplain ' dotFile]);


@Jonathan, I am using 2013a and Mac OSX 10.9

Jonathan Lister

@James, I have no idea what to tell you about that one. Sounds like the mathworks dot program is not in the right place or that your install of MATLAB has a problem. This has been working since at least 2009a, but I haven't tried it with 2013b yet. What platform and version are you using?


I followed Michael's instruction and get the error:

Error using mGraphViz (line 137)
An error occurred when trying to run
the layout engine. The system said,
"/bin/bash: mwdot: command not found

(I can see that there is a mwdot executable is inside the /bin/maci64, and have tried copying it to a new folder /bin/bash with no success)


(I can see that there is a mwdot executable is inside the /bin/maci64, and have tried copying it to a new folder /bin/bash with no success)

Aurelien Queffurust

Very nice and useful to write some developer's guide.

Jonathan Lister

Sorry for the lack of examples, and the delay in response. I've not been able to access this account until recently. I will try to include something new in the near future.

Michael Quinn

I agree that an example would be nice to show the basic usage. It took me a few minutes to figure this out. Here is my simple example:

>> mkdotfile('yourfile.m', '')
>> ha = axes;
>> mGraphViz('',ha)

reez all

can anyone post the example to used this file? i still not understand to use it.

Jonathan Lister

Thanks us. fdep is a great function to build upon many kudos to you. My intent is to use fdep as the core of a new documentation system for MATLAB. I've started with M2HTML, but have ripped out a lot of the author's original code in favor of fdep. I'll look into more error checking, if you have anything in mind please send me a note jlister1 @ utk . edu

Jim Dowd


sorry, somehow the comment got lost...

1) it would be great if the size of the arrow head could be set by an option as well...
2) it would be great to have a bit more error checking on some of the options...
[x) nice use of the pedestrian fdep, by the way...]



MATLAB Release Compatibility
Created with R2010a
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!