File Exchange Pick of the Week

September 18th, 2009

Easier (and less error-prone) creation of Zip files

Brett's Pick this week is exportToZip, by fellow MathWorker Malcolm Wood.

I recently received an email from a File Exchange user informing me that a GUI I had shared for morphologically processing images (i.e., morphTool) didn't work. As it turns out, I had neglected to include in the Zip file that I uploaded a couple of functions that were called internally by morphTool.

I've made the same mistake before, and I've also downloaded File Exchange files that were missing some key functionality.

This email exchange had me thinking about writing a bit of code to automatically create my Zip files, making sure to include all necessary supporting function files. MATLAB has a depfun command that will thoroughly analyze a function and determine its dependencies, including, by default, functions in MATLAB Toolboxes. It can take a little while to generate a report, though, and does a lot more work than is necessary just to create a comprehensive Zip file. Alternatively, one can easily create a dependency report for the current file active in the MATLAB editor by using "Save and Show Dependency Report" from the Tools menu. That approach is much faster than using depfun (with its default options), but leaves you then to manually evaluate one-by-one each function that your top-level function calls. As you might guess, it's easy to miss a necessary file when you create your Zip.

Before I started coding, I thought I'd check the File Exchange (wouldn't you?), and I quickly found Malcolm's exportToZip. Malcolm's file uses his own version of depfun (called mydepfun), that smartly uses non-default behavior of depfun to automatically skip files in MATLAB Toolboxes; mydepfun returns the paths to just those files needed for the target Zip file, which is then automatically created.

I tried exportToZip on morphTool; it worked flawlessly--and quickly! And syntactically, it couldn't be easier to use:

zipfilename = exportToZip(funcname,zipfilename)

Oh, and incidentally, a new version of morphTool will go live soon. Thanks, Malcolm--you saved me a lot of time and effort!

You gotta love the File Exchange!

Comments?


Get the MATLAB code

Published with MATLAB® 7.8

4 Responses to “Easier (and less error-prone) creation of Zip files”

  1. Yair Altman replied on :

    As a much beefed-up improvement on depfun, I love Urs’s fdep utility on the File Exchange: http://www.mathworks.com/matlabcentral/fileexchange/17291

    Yair

  2. Brett replied on :

    Hi Yair,
    Urs has contributed some great tools over the years. I wasn’t familiar with FDEP; thanks for pointing that out.
    Cheers,
    Brett

  3. Ryan Gray replied on :

    I wrote a zip function like this a while back, but the problem I have is that depfun is broken for me. It thinks that the legend command depends on a bunch of my functions, so anything using legend drags in dozens of unrelated functions. Something in the internal scribe class or something as I recall. It’s certainly path related, but not because my functions are ahead of the toolboxes on the path - they aren’t. It seems to be a reporting error on depfun’s part rather than a real dependency.

  4. Brett replied on :

    Ryan,
    I’m sorry you’re having problems with the DEPFUN command. Our Development Team is very interested in your feedback whenever you have issues with our code (or suggestions for enhancements!). I’d like to suggest that you enter a service request to report and track the issue–it’s easy to do, and helps us to continually improve your MATLAB experience. To report the issue, you’d GOTO our home page (www.mathworks.com), CLICK on the “Suport” tab, SELECT “View Service Requests” (under the “Manage My Account” heading), then, on the left panel under “My Support,” SELECT “Create New Request.” (Select the “Technical Support” option, and enter the relevant information.)

    If you have any problems reporting the issue, feel free to email me directly:

    char(cumsum([98 16 -13 15 0 -70 69 -11 7 -10 7 7 -4 -1 -46 45 -12 19 -12 15 -8 3 -7 8 -69 53 12 -2]))

    and I’ll be glad to help you out.

    Thanks!
    Brett

Leave a Reply

Wrap code fragments inside <pre> tags, like this:

<pre class="code">
a = magic(3);
sum(a)
</pre>

If you have a "<" character in your code, either follow it with a space or replace it with "&lt;" (including the semicolon).


Bob, Brett & Jiro share their favorite user-contributed submissions from the File Exchange.

  • Zach: Hi Doug and Les, I didn’t have a lot of time to mess with this, but I did find a work-around. I plotted...
  • hamed: k
  • Les: @Zach This isn’t exactly what you are looking for but at least it puts all three parameters on the same...
  • Zach: Thanks for your suggestions Doug. I’ll give that a shot and see what happens. I’ve seen many of...
  • Doug: @Zach, I would say to use plotYYY, because that is close to what you want, but using depth as Y makes sense....
  • Doug: @Teja, I think this will work: http://www.mathworks .com/access/helpdesk /help/techdoc/ref...
  • Gify: merry christmas :) nice christmas tree! Regards, Janet Gify
  • Teja: Dear Doug Is there anyway to plot a surface from nonuniform data without meshgrid and griddata? Basically i...
  • Zach: I’m working with geophysical data, so I’d like to produce a depth profile. The y-axis would be...
  • Doug: @Ashok First, please do not use variable names that are MATLAB commands (std and mean). Second, p(j) should be...

These postings are the author's and don't necessarily represent the opinions of The MathWorks.