Code covered by the BSD License  

Highlights from
Show Calling Dependency

3.25

3.2 | 4 ratings Rate this file 4 Downloads (last 30 days) File Size: 2.42 KB File ID: #15653
image thumbnail

Show Calling Dependency

by Zhengdao Wang

 

21 Jul 2007 (Updated 18 Aug 2007)

A function is provided that shows which functions a script/function calls

| Watch this File

File Information
Description

The script shows the calling sequence of a function or a script. Given the script/function name, this utility

1. displays a list of functions that are called.

2. generates a .dot file

3. uses Graphviz/dot tool to generate an .eps file that shows the dependency relationship of the functions called directly or indirectly.

4. uses gv to display the .eps file.

In order for the graphical display to work, it needs

1. The "dot" program in Graphviz. See
http://www.graphviz.org/

2. The gv (ghostview) program to show the EPS file.

System functions (those that are not in a directory whose full path name contains the user id) are ignored.

Acknowledgements
This submission has inspired the following:
dep
MATLAB release MATLAB 5.2 (R10)
Other requirements 1. The "dot" program in Graphviz. See http://www.graphviz.org/ 2. The gv (ghostview) program to show the EPS file. The program is written for Unix like environment. It may not work on other platforms.
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (6)
25 Jul 2007 Daniel Ennis

It appears to work well. It took a bit of looking to get dot installed and linked, but that isn't the author's fault. This link may be helpful for others: http://www.ryandesign.com/graphviz/faq.php#path

The program works well, but could be improved. For large programs sometimes many lines are drawn between the same two blocks. This indicates multiple calls between blocks, but can clutter the diagram a bit. Nice tool

10 Aug 2007 Sven Probst

"user = getenv('USER')", l.17 depends on the environment variable being set which is not always true. I prefer relying on JAVA:
user = char(java.lang.System.getProperty('user.name'));

Nevertheless this is a error prone way to distinguish between matlab environment and user functions as the user name must not be part of the user defined function - as in my case.
I changed to using the matlabroot function.
Line 17 changes from
user = getenv('USER');
to
matlabRootDir = matlabroot;
Line 21 changes from
if isempty(findstr(name, user))
to
if ~isempty(strmatch(matlabRootDir, name))

Adding these command line arguments to the call of dot.exe
-Gpage="7.5,10.9" -Gorientation="landscape"
results in DIN A4 page breaks.
Very helpful tool !

17 Aug 2007 Zhengdao Wang

Sven Probst: Your suggestions have been incorporated. Thanks.

Daniel Ennis: The duplicated links are removed (hopefully). It was due to multiple calling returns from depfun of Matlab. Thanks.

The new version number is: Thu Aug 16 22:29:55 CDT 2007. Version number is available in the .m file.

17 Aug 2007 E Comment

I couldn't get it to work under windows (XP) environment- It looks like a good tool and it would be great to have a version for windows as well. Perhaps I'll look into it.

21 Aug 2009 Glenn Gomes

It also looks like it is indexing native MATLAB functions; something you do not want.
I generated a .jpg from the using GrafViz, which was unreadable.

10 Jun 2010 Lukas Lansky

It worked as expected! Few suggestions:
1. Nicer output to GraphViz, than this simple one. It could have several modes.
2. Export only .dot file to the current directory option.

Please login to add a comment or rating.
Updates
18 Aug 2007

An improved version of the .m file is available.

Tag Activity for this File
Tag Applied By Date/Time
path Zhengdao Wang 22 Oct 2008 09:20:01
directories Zhengdao Wang 22 Oct 2008 09:20:01
files Zhengdao Wang 22 Oct 2008 09:20:01
calling Zhengdao Wang 22 Oct 2008 09:20:01
scripts Zhengdao Wang 22 Oct 2008 09:20:01
dependency Zhengdao Wang 22 Oct 2008 09:20:01

Contact us at files@mathworks.com