4.5

4.5 | 4 ratings Rate this file 21 downloads (last 30 days) File Size: 3.57 KB File ID: #10702

exportToZip: Identifies the dependencies of an M-file and creates a ZIP file

by Malcolm Wood

 

11 Apr 2006 (Updated 11 Apr 2006)

Code covered by the BSD License  

Files inside $matlabroot/toolbox are omitted, providing a useful way to package your work

Editor's Notes:

This file was selected as MATLAB Central Pick of the Week

Download Now | Watch this File

File Information
Description

The function "mydepfun" determines the dependencies of an
M-file, ignoring files inside the MATLAB "toolbox" directory. Skipping these files gives significant performance improvements over calling "depfun" directly, especially in MATLAB installations which include multiple toolboxes. The assumption is the same as that in "mypath.m", i.e. that most of us do our work in directories outside $matlabroot/toolbox.

The function "exportToZip" creates a ZIP file containing all the dependencies identified by "mydepfun" for one or more MATLAB functions. This simplifies the process of passing your work to another user, or uploading it to MATLAB Central, by reducing both the effort required and the likelihood of a file being missed out.

The limitations of "depfun" apply: for example, that dependencies introduced by calls such as "eval('peaks')" are not identified. An additional limitation is that if files in the MATLAB toolbox directory somehow depend on files *outside* that directory (e.g.
if you have overloaded toolbox functions), these dependencies will not be picked up as they would by "depfun" itself.

The directory hierarchy is preserved by "exportToZip", which means that all required files must be on the same drive so that a "common root directory" can be determined.

Acknowledgements

The author wishes to acknowledge the following in the creation of this submission:
depfun2, DepSubFun, mypath.m

MATLAB release MATLAB 7.2 (R2006a)
Other requirements Should work on any platform (though has only been tested on Windows) and any release since R14 (MATLAB 7.*).
Zip File Content  
Other Files exportToZip.m,
mydepfun.m
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (5)
02 Jun 2006 mut ante

hi: i have the habit of mixing upper and lower case when writing important folder names... the function worked properlly after changing the string comparison functions to the corresponding ignore case functions... well this is admissible in a win system, but.... thx for this function

13 Sep 2006 Murphy O'Brien

Great! This is just what I needed. It's perfect for releasing code to a user and also a handy way of making a new directory without all the useless files that somehow get created on the way.

26 Sep 2008 Tim Tam

mydepfun does not appear to find dependencies of dependencies ? When I used ML's depfun it returned 30 non-toolbox m files (plus one custom DLL), while your mydepfun returned only 13 m files.

19 Nov 2008 Thierry Dalon

Comment on Tim Tam comment:
look at the option 'recursive' of mydepfun.
exporttoZip uses this option so you get all dependencies.

21 Dec 2009 Brett Shoelson

I second mut ante's observation, and his suggestion for improvement. This function, which has earned a spot on my shortcut bar, fails in certain cases because of case sensitivity. I replaced all instances of STRNCMP with STRNCMPI in subfunction i_root_directory, and the problem went away.

Please login to add a comment or rating.
Tag Activity for this File
Tag Applied By Date/Time
path Malcolm Wood 22 Oct 2008 08:21:59
directories Malcolm Wood 22 Oct 2008 08:21:59
files Malcolm Wood 22 Oct 2008 08:21:59
export Malcolm Wood 22 Oct 2008 08:21:59
function Malcolm Wood 22 Oct 2008 08:21:59
dependencies Malcolm Wood 22 Oct 2008 08:21:59
mfile Malcolm Wood 22 Oct 2008 08:21:59
depfun Malcolm Wood 22 Oct 2008 08:21:59
potw Shari Freedman 18 Sep 2009 10:57:01
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com