Skip to content

Installing MATLAB

At your own computer

The instructions to install vary a bit based on which operating system you are using, but they are all essentially the same. Please note that you need to have a license to run MATLAB. As a LiU student or employee, this should already be available to you.

  1. Download the installer for your operating system from the MathWorks homepage. If you do not have a valid account, you need to first create one.
  2. Install MATLAB from the downloader you downloaded earlier. Choose to log in as the installation method, and log in with your MathWorks account. You do not need to install all packages and do not need Simulink. You probably want the Statistics and Machine Learning Toolbox, Optimization Toolbox, Global Optimization Toolbox and Parallel Computing Toolbox toolboxes if possible.
  3. Install a C-compiler (see instructions below).
  4. Start MATLAB and setup any additional packages needed.

For detailed instructions about installing MATLAB, follow the guide by MathWorks.

Installing a C-compiler

To compile the models to C-code (also known as MEX-files) for faster simulation, you need to have a valid C-compiler. An official list of supported compilers for each operating system is available here. Below we offer some quick steps of installing a valid compiler on Windows, Linux or MacOS.

Windows

The easiest way is to open MATLAB and find the AddOns button (stacked cubes), and search for MinGW and install the MATLAB Support for MinGW-w64 C/C++ Compiler.

Alternatively, one can install a general compiler as described here.

Linux

You probably already have a compiler available, otherwise install e.g. gcc through your package manager.

MAC

To get a C-compiler, you need to install Xcode. Xcode is available in the Mac app store. After installation, start Xcode and agree to the license agreement.

It might also be possible to install gcc, e.g. by opening a terminal and typing gcc which should prompt a request for installing Command line developer tools.

After installing the compiler, restart MATLAB.

To verify that MATLAB sees a compiler, run mex -setup in the MATLAB command window. You should get information about what compiler is selected.

At a computer in a LiU computer hall

Linux

If you are at a LiU shared computer running Linux (such as in the SU halls, or when logged in via ThinLinc), you need to first load the MATLAB package. To check which versions of MATLAB is available, open a terminal and run:

module avail | grep matlab

This should print a list of available MATLAB packages you could load. You probably want to use the version marked with (recommended) Then to load the MATLAB package and make it available, write the following into the terminal:

module add matlab/9.13

Note that matlab/9.13 might have to be changed if other versions are found using the module avail command.

Finally, to start MATLAB run:

matlab &

Windows

MATLAB should/might already be available at the computer. If not, you need to change computer or connect to another computer using e.g. ThinLinc.