Using Matlab at the MPI CBS
Permanent Link:
Overview
Main Matlab use case in the institute is a
Linux application. Matlab is available in several versions, installed centrally in network folders, available to all users working on Linux workstations/servers in the institute's core network. A license server watches over everything to ensure that we don't cheat Mathworks. The license server is accessible from the core network only, Matlab instances will stop working instantly upon its unavailability.
To use Matlab from outside the institute, use the
RemoteLinux service to connect to a graphical session in the institute's core network.
The
only supported way of starting Matlab is via a wrapper script. The installation folders of Matlab are subject to change--without prior warning!
FAQ
How to quickly use Matlab?
The simplest way is to start it in a terminal window with
user@host >
matlab
This will start the Matlab GUI, using the latest available Matlab releases.
There are other use cases for Matlab. You might for example want to compile a Matlab script into a piece of software that is independent of an expensive Matlab license. To get help, use the command
user@host >
MATlAB --help
How to ensure a specific Matlab version?
Permanent Link:

You might have to make sure force a specific version of Matlab to ensure reproducible results. Find some theory about that at
https://topic.cbs.mpg.de/enterprisecomputing#consistency .
You might prefer to use a different release. It is encouraged to stick to the same Matlab release while doing computations for a given research project since computational results change with Matlab releases (Example measurement:
CpuMatlabPrecision). Find out, which releases are available via
user@host >
MATLAB --versions
MATLAB
is an
environment wrapper script. Since there are many more things you can do with Matlab than just start the GUI, there's an abstraction between selecting the release (=starting the environment) and starting the GUI. Here are some commands that may be of interest to you:
This example shows Matlab 9.15 being selected in step one and the GUI being started in step 2:
user@host >
MATLAB --version 9.15
matlab=9.15_user@host >
matlab
This example does the same in one command:
user@host >
MATLAB --version 9.15 matlab
To run a Matlab script from within a shell script, use this call:
MATLAB --version 9.15 matlab -r 'my_matlab_function'
The call will fail, if the requested version cannot be supplied by the system. This represents a hard guarantee for you that your script will never be run, if your version constraint cannot be met.
Hints:
- Type
MATLAB --help
for help on the wrapper script.
- Use a shell alias to quickly start Matlab in your preferred version.
- Several different Matlab releases can be used--even simultaneously.
- If you have trouble with Matlab, try this command:
user@host >
clearmatlab
to remove your per-user Matlab configuration.
- Matlab's GUI tends to be unstable due to the way it is made up internally. Matlab can be used without a GUI--e.g. for bulk computations. Try this:
user@host >
MATLAB matlab -nojvm
- You are not limited to the computational power of your workstation. For bulk computations, a compute server might be more suitable. Connect to one using this command:
user@host >
getserver -sL
and start Matlab there. Disable the GUI (previous hint) for an increase in performance.
- For really large sets of independent computations, you might want to consider using a Cluster.
Permanent Link:

There are a lot of Toolboxes available for Matlab. Toolboxes are basically collections of self-written Matlab functions. Sometimes this includes resources (e.g. example brain images).
If you require SPM: The institute already offers an easy-to-use SPM installation. Find information about that at
SoftwareSpm .
For other toolboxes, feel free to install those by yourself. Some information first:
- Toolboxes are just sets of files containing Matlab-functions.
- There are rules for Matlab, where to look for these files.
- You are able to influence these rules.
- Every use is entitled to storage for custom software installation. If you already requested this storage, find it at
/data/u_${yourloginname}_software
( e.g. /data/u_smithjohn_software
).
To install and use a toolbox, follow these steps:
- Make a new folder in your custom software storage - e.g.
/data/u_smithjohn_software/matlab/eeglab
- Put your Toolbox's files there.
- Make sure to let Matlab search this folder for functions. There are two ways:
- Set a search path in the Matlab GUI
- Set the responsible environment variable before starting Matlab.
- Example:
export MATLABPATH="$MATLABPATH${MATLABPATH:+:}/data/u_smithjohn_software/matlab/eeglab"
- This is actually "modifying" the variable instead of "setting" it. Reason is that it might already contain a set of valuable paths which you implicitly need. This command adds your folder to the end of the path list.
- This has to be done every time, you start Matlab.