While this has only been tested in version 7.9 (R2009b) and 7.11 (R2010b) of MATLAB, there is no reason to believe that the procedure should be any different in past and future releases of MATLAB that include the function deploytool. If you want to deploy a script to use on a cluster (e.g. the Martinos center's), I believe you will need to use MATLAB on Linux (e.g. on the Martinos center's computers), not on Windows. If you use the same procedure on Windows, you will create a .exe instead of a .sh script. There might be a way to create a .sh script on Windows, but I am unaware of it at the moment; please let me know if you find one.
It is not the intention of the author of this web page to provide further scripting or command support than what is included in this webpage. This webpage has been written to provide support to the Martinos center cluster users, but can easily be used elsewhere.
This procedure assumes that you have a script ready that only requires text inputs (strings) and that send all outputs to file(s) (whatever the format, could be text files with fwrite/dlmwrite, MRI images with MRIwrite, MATLAB .mat files with save, etc). I normally only provide the path to the data directories or files as inputs. You will be able to later write a shell script wrapper that will use the deployed MATLAB script in a parallel manner (e.g. using a foreach loop that will provide the data directory of each of your subjects). You might also want to avoid using parfor and parallel tools in MATLAB as you will be able to launch multiple instances of your application anyway (e.g. if you want to process several subjects).
Type deploytool at the MATLAB prompt. This will open a the Deployment Project window.
Give a Name and Location to your project, and select Standalone Application as the Target (should be the default on the Martinos center computers). The Name will correspond to the resulting output script. Again, you need to be on Linux to produce a .sh script, otherwise it will produce a .exe file if you are on Windows.
Under the default Build tab of the Deployment Tool window, select Add main file and select your main script. While I always try to have a single .m file for my application and never tested having multiple files, you can add other files using Add files/directories. You don't need to add any script file already provided with MATLAB or any of its installed toolboxes. I believe you might not need to manually add anything that is on your MATLAB path either, other than the main script you wish to deploy. If you wish to use the script on a computer that does not have MATLAB installed, you will want to check Add MCR under the Package tab (no need to do that if you plan on using the cluster at the Martinos center).
Click on Build, the first button next to the project name in the Deployment Tool window, or under Project in the menu when the Deployment Tool window is selected. This will create a folder with the same Name in the same Location, with two subfolders, src and distrib, both containing the same scripts run_Name.sh and Name in addition to a readme.txt file, with distrib also containing the MCR package if you added it.
You will need to define an environment variable defining the path to the installed MCR package. If you are at the Martinos center, you can simply define it by typing
setenv MCR /usr/pubsw/common/matlab/7.11/substituting with the MATLAB version you are using at the end, provided it is supported by the Martinos center.
If you want to use the script on your own computer, all you have to do is to type
./run_Name.sh $MCR input1 input2 ...if you are in the same directory, or write the full path to the script
Location/src/run_Name.sh $MCR input1 input2 ...
If you want to use the script on the Martinos center's cluster, you need to login to launchpad using the regular
ssh launchpadand then type as usual, with or without optional parameters to pbsubmit,
pbsubmit -c "Location/src/run_Name.sh $MCR input1 input2 ..."
Note that you can move the files run_Name.sh and Name out of their original location as long as they stay in the same directory.