Matlab

How to use Matlab on the platform
Matlab installations are a little simpler to figure out and launch compared to Python/Conda. As Matlab is a licensed product the installations are provided through DTU centrally and its maintenance is therefore outside of the hands of QIM.

Starting Matlab

# – Launch from menu – #
Applications -> DTU -> Mathematics -> Matlab (default)

This will start Matlab 2021b on a normal “random” node!
There may be good cases where selection from the menu-bar won’t simply do, e.g.:

  • The need to run a specific Matlab version
  • The need to launch Matlab on a specific type of compute node

In all of those cases, Matlab needs to be called from a terminal as described below.

# – Launch from terminal – #

The cluster uses environment modules, which need to be loaded prior to launching Matlab:

  • Launch a terminal on the desired node type
  •  
  • If the default version of Matlab is fine just call
  • matlab
  •  
  • If a specific version of Matlab is required the following commands are useful:
  • To see available modules call:
  • module avail matlab*
  • Activate matlab module by calling e.g.:
  • module load matlab/R2020a/
  • Start matlab with command:
  • matlab

Legacy versions: DTU is naturally committed to supporting reproducible research, and older versions of Matlab going back a couple of years are generally available. For more info go here.

Matlab toolboxes and functions

The university license gives access to ‘all’ official MathWorks toolboxes, which should already be installed.
The following will focus on custom-made and specialized packages developed by either the Matlab community or QIM/3DIM

# – QIM specific functions/toolboxes – #
The 3D Imaging Center and QIM provide a repository of certain useful Matlab functions for analysis, either of our own making or from other scientists via e.g. MathWorks. These functions are of general relevance and (generally) made with sufficient documentation, and is found here:

Location on the platform: /dtu/3d-imaging-center/QIM/toolbox_matlab

💡 Make it a habit of adding the folder to Matlabs path at the beginning of any script, by adding the following lines of code:
foldTbox = ‘/dtu/3d-imaging-center/QIM/toolbox_matlab’;
genpath(addpath(foldTbox))
NB: These functions may be subject to change and modification without prior warning. We strive to make functions backward compatible, but no guarantees are given.

# – Project specific functions – #
During the process of data analysis several functions might be developed or obtained from other sources (e.g. the MathWorks user community).
We recommend that you store these within the project analysis folder, such that any project collaborator can easily access them. Make a separate folder, and add the folder path at the top of scripts:

genpath(addpath(‘../analysis/matlabFuns/’)

If your functions can be made generic, and could have a broader interest than just your project, contact someone from QIM and we may consider placing it in our repository where it is more generally available.

NB: If you are using functions from the QIM repository, it may be wise to take a copy of those and place them in your project folder at some point to ensure reproducibility. This is particularly true if your data analysis has gone into a publication. We (3DIM/QIM) will strive to keep functions backward compatible and keep copies of older functions, but in the end the responsibility of reproducibility lies on those involved in specific projects!