MATLABStarter is a series of startup functions for MATLAB that dynamically add MATLAB .m files, Java folders and .jar archives in user- or administrator-defined folders to the MATLAB path and optionally updates any subversion or git working copies found.
MATLABStarter can be used to set up a multi-user environment (e.g. a facility) or for personal use and relies on the presence of one or more environment variables.
To use automatic code update, make sure to have subversion version 1.6 or higher and/or git installed and in the path. Moreover, users should have read/write access to the working copies for the automatic update to work.
If you want to set up MATLABStarter for a shared environment, you should download and extract the four functions startup.m, envvars.m cgenpath.m and updateRepositories.m in the toolbox/local subfolder of the MATLAB installation directory.
This will be something like:
Windows: C:\Program Files\MATLAB\R2012a\toolbox\local Mac OS X: /Applications/MATLAB_R2012a.app/toolbox/local/ Linux: /opt/MATLAB/R2012a/toolbox/local
Considering that every new version of Mac OS X makes it one step harder to set environment variables that are visible from applications not started via the terminal, MATLABStarter v0.2 adds an alternative (optional) method to simplify this step.
Since MATLABStarter v0.2, the global environment variables (see below) can be set in the envvars.m file. The instructions below will help you set them in the classic way.
The only mandatory environment variable is MATLABHOME.
In a shared environment, MATLABHOME should be set at system level (i.e. set for all users) and point to a folder that contains the code to be visible to all users. It you are the only user of MATLAB in your machine, MATLABHOME can also be set for your account only.
The optional environment variable MATLABUSERFOLDER is meant for individual users to add their own folders to the MATLAB path. MATLABUSERFOLDER is added at the top of the path and MATLAB will change to MATLABUSERFOLDER at the end of startup, so that users can directly work in their user folder. Setting MATLABUSERFOLDER makes most sense in a shared environment: on a single-user environment, set MATLABHOME instead.
The optional environment variable IMARISPATH is used in combination with IceImarisConnector and should point to the $IMARIS_ROOT_DIR folder. Notice that this variable is only used on Windows and Mac OS X and ignored on Linux.
One last optional environment variable to be used in combination with ImarisConnector is XTENSIONS, that should point to the $IMARIS_ROOT_DIR/XT/matlab folder. Notice that this variable is only used on Windows and ignored on Mac OS X and Linux.
Edit the envvars.m file and set the following variable (uncomment the relevant entries):
% Set the environment variable contents here % ========================================================================= % MATLABHOME is mandatory for the functioning of MATLABStarter. Make sure % it is set either here or externally. % MATLABHOME = ''; % Optional % XTENSIONS = ''; % IMARISPATH = ';
If you are planning to set the environment variable externally, leave all entries commented out.
MATLABUSERFOLDER must still be set externally.
If you are setting up MATLABStarter just for yourself, you can set all three variables MATLABHOME, MATLABUSERFOLDER and XTENSIONS as user variables.
To set the system variables (you need to have administrator privileges), edit the file /etc/profile and add the following at the end (this assumes you are using bash):
export MATLABHOME=/path/to/global/MATLAB/folder
To set the user variables, edit the file ~/.bash_profile and add the following at the end:
export MATLABUSERFOLDER=/path/to/your/MATLAB/folder
You need to log out and back in for changes to take effect.
On Windows Vista and 7, click on the Start button and type "environment variables". You will get two options, use Edit the system environment variables to set system-wide variables, and Edit environment variables for your account to set user variables.
Following dialog will open:
In the top field you can set the MATLABUSERFOLDER variable:
Variable: MATLABUSERFOLDER Value: D:\Devel\MATLAB
In the bottom field you can set the system-wide MATLABHOME and XTENSIONS variables:
Variable: MATLABHOME Value: C:\MATLAB
Variable: XTENSIONS Value: C:\Program Files\Bitplane\Imaris x64 7.4.0\XT\matlab
On Windows XP, right-click on My Computer and choose Properties; follow the instructions as for Windows Vista and 7.
Mac OS X Lion seems to ignore all attempts to set environment variables. Here are two suggested attempts.
One method that seems to work reliably for system-wide environment variables is by setting the environment variables in /etc/launchd.conf as follows:
setenv MATLABHOME /path/to/MATLAB/folder
User variables should then be set in ~/.launchd.conf, though this does not seem to work...
setenv MATLABUSERFOLDER /path/to/your/MATLAB/folder
For good measure, reboot for the changes to take effect.
In Snow Leopard (and in some circumstances in Lion), the best way is to create a file called environment.plist with following content and put it in a hidden folder .MacOSX in the home directory:
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>MATLABHOME</key> <string>/path/to/MATLAB/folder</string> <key>MATLABUSERFOLDER</key> <string>/path/to/your/MATLAB/folder</string> </dict> </plist>
Drawback of this approach is that it sets the environment variables for current user only.
A nice tool to edit ~/.MacOSX/environment.plist is rubicode's RCEnvironment (use this in Snow Leopard).
This post suggests to convert the ~/.MacOSX/environment.plist in Lion to binary as follows:
plutil -convert binary1 ~/.MacOSX/environment.plist
This does not seem to work in Mountain Lion...