(Last modified: 2020-04-05)
This post was intended as a note to myself, but I put it online in the hope it can be useful to others. Feel free to report any error, or to share your tips and tricks.
I don’t really like Matlab, especially because it’s a closed-source proprietary software. However, as most researchers in my field use it to implement their algorithms, I often have to use it. And it doesn’t always work well with GNU/Linux, so here is a list of issues I had and how they were solved. I use Matlab on Linux Mint 19, but this should work for any Debian-based distribution, such as Ubuntu.
Package matlab-support
The package called matlab-support
1 is a must-have. It configures existing Matlab installations to integrate smoothly in your GNU/Linux environment, and behave like any other package.
In short:
- It creates menu shortcuts for the installed versions of Matlab.
- It solves the conflicts between the libraries shipped with Matlab and some GNU/Linux libraries.
- It is used by other packages, for example to compile MEX files.
To install it, open a terminal and type apt update && apt install matlab-support
. A configuration menu should appear, where you have to tell the location of Matlab on your disk.
If you want to change something, or if you install a new version of Matlab, update the package configuration with the command dpkg-reconfigure matlab-support
.
Crash at startup
I experienced crashes at startup (that is, Matlab crashes a moment after I open it) for different reasons. Here, I present the solutions that worked for me.
You don’t have rights on the config folder of Matlab
Just change the rights of the folder. Open a terminal, and type
sudo chmod -R 755 ~/.matlab
.
Some libraries are not linked properly
If libraries appear to be missing to Matlab, they may be installed but not visible. To solve this, open a terminal, and type
sudo ln -s /usr/local/MATLAB/R2019b/extern/include/mex.h /usr/include/
This is an example with the mex.h
library, but you can replace it by the libraries your Matlab installation is missing.
The startup folder doesn’t work
You defined a startup folder in Matlab’s preferences, or configured it to open the last working folder, and it didn’t work?
Try to open the launcher file (usually, /usr/share/applications/matlab.desktop
) and add -useStartupFolderPref
at the end of the line Exec
. It worked for me!
Matlab and emacs
If you use emacs to work with Matlab code files, the package matlab-mode
is way nicer than the default mode.
You can install it via the usual list-packages
.
You can configure emacs to automatically open .m files in this mode by adding the following line to your .emacs:
(add-to-list 'auto-mode-alist '("\\.m\\'" . matlab-mode))