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.

# – Launch from menu – #

Applications -> Mathematics -> Matlab

This will start Matlab 2020a on a normal “random” node!

There may be good cases where selection from the menu-bar won’t simply do, e.g.:

  • You need to run a specific Matlab version
  • You need to launch Matlab on a specific node – see PAGE: NODES – e.g. for bigmem, GPU support, as part of a batch/shell script for submission to HPC system etc.

In all of those cases, Matlab needs to be called from a terminal. The cluster uses environment modules – SEE PAGE MODULES – which need to be loaded prior to launching the program:

# – Launch from terminal – #

  • Launch a terminal (on desired node)
  • To see available modules call e.g. module avail matlab*
  • Activate matlab module by calling module load matlab/R2020a/
  • Start matlab with commandmatlab

Legacy versions: DTU is naturally committed to supporting reproducible research, and older versions of Matlab going back a couple of years are generally available.
Some more info can be found \href{https://www.hpc.dtu.dk/?page_id=3246}{here}.

# ——————————————————- #
Matlab TOOLBOXES:
The university license gives access to ‘all’ official MathWorks toolboxes, and these should already be installed. For additional needs see below.

# ——————————————————- #
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 3DIM:
/dtu/3d-imaging-center/QIM/toolbox\_matlab

These functions and toolboxes are added and maintained by people from either QIM or 3DIM.

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))

!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.

!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!