Matlab distribution nightmares…

I am getting to the point where I have to seriously test, debug, refactor, and document my Matlab code. I have already spent a lot of time on a first round of refactoring, changing my main file from many thousands of lines of code to a couple of hundred. This means I have many more Matlab functions cluttering up various folders.

This got me thinking how I could easily bundle my code so I can show it to my supervisor or add it to my thesis. So I spent a couple of hours today doing some research and came up with MRcopyForDistribution(). It doesn’t do any error checking yet and assumes you know what you are doing in terms of input… so beware!

If you run it without any arguments (probably the best way of using it) a GUI window pops up where you can select your main file:

Here I am selecting MRdiffusetest_15.m:


After some thinking on Matlab’s part, it opens up a finder window, complete with a new folder with today’s date and name of the file you selected in the above step. Inside that new folder you will find a number of things:

You will notice two text files, a folder named lib_files, and the file you selected in the folder above. The two text files contain lists of dependencies. There are two types of dependencies that are important to distinguish between in Matlab. 1) Matlab specific (and version specific) dependencies; 2) third party function/library dependencies.

So for this example we have the following Matlab dependencies. This means you can only run this code if you have the following Matlab Toolboxes installed:

The other text file lists the names of all the third party/libraries that are in use:

The lib_files folder holds copies of all the dependencies files.

Here you have it! A copy of all dependency files needed to run your project in one folder, ready to be zipped up and sent on its merry ways.

Here is a link to the function so you can test it: MRcopyForDistribution

 

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>