Ubuntu installs Matlab2021b

2022-01-07
#Unix #Matlab #Ubuntu

1. Steps

  1. Download the matlab_R2021b_glnxa64.zip at the matlab page https://ww2.mathworks.cn/licensecenter/licenses

  2. Unzip and install:

unzip matlab_R2021b_glnxa64.zip
cd matlab_R2021b_glnxa64/
./install

Note that the difference between sudo ./install (for root) and ./install (for current user).

When installing matlab, the paths are /home/deng/MATLAB/R2021b other than /usr/local/MATLAB/R2021b and /home/deng/bin other than /usr/local/bin.

  1. Add the command matlab into the file ~/.bashrc by:
gedit ~/.bashrc
alias matlab=\''/home/deng/bin/matlab'\'
source ~/.bashrc
  1. Add the Pin icon to Favorites:
cd ~/.local/share/applications
sudo gedit matlab.desktop

add the contents into matlab.desktop

[Desktop Entry]
Categories=Application;Development;
Encoding=UTF-8
Exec=/home/deng/MATLAB/R2021b/bin/matlab -desktop
Icon=/home/deng/MATLAB/R2021b/toolbox/shared/dastudio/resources/MatlabIcon.png
Name=MATLAB2021b
StartupNotify=true
Terminal=false
Type=Application

PS: Icon=/home/deng/MATLAB/R2021b/bin/glnxa64/cef_resources/matlab_icon.png

  1. Solve the problem Gtk-Message: 15:06:42.429: Failed to load module "canberra-gtk-module"
$ sudo apt install libcanberra-gtk-module
$ sudo apt install mlocate
$ locate libcanberra-gtk-module.so
/snap/gnome-3-34-1804/72/usr/lib/gtk-3.0/modules/libcanberra-gtk-module.so
/snap/gnome-3-34-1804/77/usr/lib/gtk-3.0/modules/libcanberra-gtk-module.so
/snap/gnome-3-38-2004/87/usr/lib/gtk-3.0/modules/libcanberra-gtk-module.so
/usr/lib/x86_64-linux-gnu/gtk-2.0/modules/libcanberra-gtk-module.so
/usr/lib/x86_64-linux-gnu/gtk-3.0/modules/libcanberra-gtk-module.so

Just establish a soft connection. Matlab uses the module of gtk-2.0:

sudo ln -s /usr/lib/x86_64-linux-gnu/gtk-2.0/modules/libcanberra-gtk-module.so /usr/lib/libcanberra-gtk-module.so

2. Reference