MATLAB: Difference between revisions

From ArchWiki
m (→‎Using webcam/video device: improved typesetting)
(→‎Troubleshooting: I added a new fix to a possible error that could happen when installing matlab since it was not mentioned in the wiki and I found several posts that asked for a possible solution for this problem but only one of them had an answer with the right solution)
 
(152 intermediate revisions by 40 users not shown)
Line 7: Line 7:
{{Related|Mathematica}}
{{Related|Mathematica}}
{{Related articles end}}
{{Related articles end}}
{{Style|unnecessarily verbose}}
{{Style|unnecessarily verbose, sometimes written in in first person}}
From the [http://www.mathworks.com/products/matlab/ official website]:
From the [https://www.mathworks.com/products/matlab.html official website]:


:''MATLAB is a high-level language and interactive environment for numerical computation, visualization, and programming. Using MATLAB, you can analyze data, develop algorithms, and create models and applications. The language, tools, and built-in math functions enable you to explore multiple approaches and reach a solution faster than with spreadsheets or traditional programming languages, such as C/C++ or Java.''
:MATLAB is a programming and numeric computing platform used by millions of engineers and scientists to analyze data, develop algorithms, and create models.


== Overview ==
== Overview ==
Line 16: Line 16:
MATLAB is proprietary software produced by The MathWorks and requires a license to obtain, install, and activate. New versions of MATLAB are released twice a year,
MATLAB is proprietary software produced by The MathWorks and requires a license to obtain, install, and activate. New versions of MATLAB are released twice a year,
release names are composed of {{ic|R}}, the year of the release and {{ic|a}} or {{ic|b}}.
release names are composed of {{ic|R}}, the year of the release and {{ic|a}} or {{ic|b}}.
Since R2012b MATLAB has only been available for 64-bit Linux. Arch Linux is not officially supported.
Arch Linux is not officially supported.
[http://www.mathworks.co.uk/support/sysreq/current_release/index.html]
[https://www.mathworks.com/support/requirements/matlab-linux.html]


== Installation ==
== Installation ==
A complete copy of the MATLAB software must be obtained before it can be installed. The MATLAB software is available to licenses holders on both a DVD and through the [https://www.mathworks.com MathWorks website]. In addition to the software a file installation key is required for installation. It is possible to install MATLAB either with the [https://github.com/mathworks-ref-arch/matlab-dockerfile/blob/main/MPM.md MATLAB Package Manager], {{AUR|matlab}}, or from the MATLAB installation software directly. The recommended and most robust method is by using the MATLAB Package Manager, as it automates the installation of both MATLAB and toolboxes. Since the standard MATLAB installer does not support Wayland, the MPM is the only way to install MATLAB if running Wayland. Please note that MATLAB itself will require xwayland. 


A complete copy of the MATLAB software must be obtained before it can be installed. The MATLAB software is available to licenses holders on both a DVD and through the [http://www.mathworks.com The MathWorks website]. In addition to the software a file installation key is required for installation. It is possible to install MATLAB either with the {{aur|matlab}} package from the [[AUR]] or from the MATLAB installation software directly. The advantage of the {{aur|matlab}} package is that it manages dependencies and some of the nuances of the installation process while installing directly from the MATLAB installation software can be done by regular users to their home directories and works for any release of MATLAB (the {{aur|matlab}} package only works for releases including and after R2010b).  
=== Installing with MATLAB Package Manager (MPM) ===
 
[https://github.com/mathworks-ref-arch/matlab-dockerfile/blob/main/MPM.md MATLAB Package Manager] (MPM) offers a streamlined method to install MATLAB and accompanying MathWorks products on Linux systems, directly from the command line. This utility facilitates programmatic installation without necessitating user sign-in, a File Installation Key, or a pre-acquired license file, deferring activation and licensing to post-installation. MPM permits specification of MATLAB release version, additional toolboxes, and installation directory. Additionally, it serves well for constructing MATLAB Docker containers. As of 2023, the MATLAB installer does not support Wayland, and this is an easy way to install MATLAB via command-line.
 
Here's how to acquire MPM and set it up for execution (ensure wget is installed):
 
{{hc|wget https://www.mathworks.com/mpm/glnxa64/mpm|chmod +x mpm}}
 
Installation of MATLAB and desired products is conducted with the following syntax:
 
./mpm install --release=<release> --destination=<destination> [--products] <product1> <product2> [...]
 
For instance, to install MATLAB R2021b along with select toolboxes to a specified directory, the command would be:
 
./mpm install --release=R2021b --destination=/home/username/matlab MATLAB Simulink Deep_Learning_Toolbox Parallel_Computing_Toolbox
 
The full list of correctly formatted product names can be found within the [https://github.com/mathworks-ref-arch/matlab-dockerfile/tree/main/mpm-input-files template input files].


=== Installing from the MATLAB installation software ===
=== Installing from the MATLAB installation software ===


The MATLAB installation software is self contained and does not require any additional packages to install in silent mode. To install with the GUI a working [[Xorg]] graphical display is necessary. [[Wayland]] is not currently supported yet. The installation is handled by the {{ic|install}} script. You can run the script as root to install MATLAB system-wide or your user to install it only for you.
The MATLAB installation software is self contained and does not require any additional packages to install in silent mode. To install with the GUI a working [[Xorg]] graphical display is necessary. [[Wayland]] is not officially supported yet, so it will run in a Xwayland session. The installation is handled by the {{ic|install}} script. You can run the script as root to install MATLAB system-wide or your user to install it only for you.
 
MATLAB 2016a and earlier is not compatible with {{Pkg|ncurses}} 6, so you must install the {{AUR|ncurses5-compat-libs}} package. See [[#Segmentation fault on startup]] for more info.


During the installation, you are asked if you want symlinks to be created. If you did not choose to do so, you can now manually create a symlink in {{ic|/usr/local/bin}} to make it easier to launch in terminal:
During the installation, you are asked if you want symlinks to be created. If you did not choose to do so, you can now manually create a symlink in {{ic|/usr/local/bin}} to make it easier to launch in terminal:
Line 34: Line 49:


Or you could add  MATLAB install path to {{ic|PATH}} environment variable.
Or you could add  MATLAB install path to {{ic|PATH}} environment variable.
{{Note|If the installation crashes with {{ic|Failed to launch web window with error: Unable to launch the MATLABWindow application.}}, see [[#Unable to launch the MATLABWindow application]] for a workaround.}}


==== Desktop entry ====
==== Desktop entry ====
Line 46: Line 63:
In order for icons to appear correctly {{ic|StartupWMClass}} needs to be set in the desktop entry. To find it out start MATLAB, run {{ic|xprop {{!}} grep WM_CLASS}} and select the MATLAB window.
In order for icons to appear correctly {{ic|StartupWMClass}} needs to be set in the desktop entry. To find it out start MATLAB, run {{ic|xprop {{!}} grep WM_CLASS}} and select the MATLAB window.


Example desktop entry (replace '''R2019a''' with your MATLAB version):
Example desktop entry:  


{{hc|1=/usr/share/applications/matlab.desktop|
{{hc|/usr/share/applications/matlab.desktop|2=
2=[Desktop Entry]
[Desktop Entry]
Version='''R2019a'''
Type=Application
Type=Application
Terminal=false
Terminal=false
MimeType=text/x-matlab
MimeType=text/x-matlab
Exec=/usr/local/MATLAB/'''R2019a'''/bin/matlab -desktop
Exec=/usr/local/MATLAB/R20''xyz''/bin/matlab -desktop
Name=MATLAB
Name=MATLAB
Icon=matlab
Icon=matlab
Line 63: Line 79:


If one need to set environment variable, one could prepend {{ic|env}} in {{ic|Exec}}, for example, to system's libfreetype:
If one need to set environment variable, one could prepend {{ic|env}} in {{ic|Exec}}, for example, to system's libfreetype:
{{bc|
<nowiki>Exec=env LD_PRELOAD=/usr/lib/libfreetype.so.6 matlab
</nowiki>
}}


One might wanna use system's {{ic|libstdc++}}.
Exec=env LD_PRELOAD=/usr/lib/libfreetype.so.6 matlab
 
One might want to use the system's {{ic|libstdc++}}.


=== Installing from the AUR package ===
=== Installing from the AUR package ===


The EULA for the proprietary MATLAB software is restrictive. The {{aur|matlab}} package from the [[AUR]] is designed to allow MATLAB to be integrated into and managed by Arch. The package should be built on the system on which it is going to be installed and the package should be deleted from the installation location and the [[Pacman]] cache following installation. Distributing the package is a clear violation of the EULA.
The {{AUR|matlab}} package is designed to allow MATLAB to be integrated into and managed by Arch. The advantage of the {{AUR|matlab}} package is that it manages dependencies and some of the nuances of the installation process. Note however, that the package does not contain the installation files, and you are expected to place them in the cloned package folder yourself. It can be problematic to build the package using [[AUR helpers]], so you are expected to do so manually. You can obtain the actual MATLAB software using the installer from [https://www.mathworks.com the MathWorks website].


The {{aur|matlab}} package from the [[AUR]] defaults to building a package for the most recent 64-bit release of MATLAB, one could also install old releases, eg. {{aur|matlab-r2015b}}. The {{aur|matlab}} package from the [[AUR]] requires that both the MATLAB installation software and the file installation key are available in the source directory.
{{Warning|The EULA for the proprietary MATLAB software is restrictive and it prohibits distribution and modification of the installation files. The installation method described in this section should only be performed on the system on which the software is going to be installed and the package should be deleted from the installation location and the [[pacman]] cache following installation. Redistributing the built package is a violation of the MATLAB EULA.}}


In order to install Matlab from AUR, download the PKGBUILD file from AUR. Download the zip file containing the Matlab installer. Then, run the installer to download necessary files:
* Clone the {{AUR|matlab}} package and {{ic|cd}} into it.
 
* Download the zip file containing the MATLAB installer from MathWorks into the current directory. Extract the zip to the {{ic|matlab}} subdirectory:
  bsdtar xC matlab -f matlab_R2019a_glnxa64.zip
  $ bsdtar xC matlab -f matlab_''XXXXX''_glnxa64.zip
  ./matlab/install
* Run the extracted installer with:
 
  $ ./matlab/install
Make sure you check all the boxes of the toolboxes you would need, and wait until the download is finished. Make sure not to close the installer. You can locate the downloaded files:
* The installer gives you a choice of either installing the software now or only downloading selected modules. Choose the second option. This option may also be under the "Advanced Options" dropdown menu.
 
* The installer will give you an option to change the download path. You might want to change it to something temporary (like {{ic|/tmp}} if you have big enough ram disk) as you will soon move the contents to a different location.
sudo find /tmp -name "tmw*"
* Wait for the download to finish and close the installer. Merge the downloaded archives into the extracted {{ic|matlab}} subdirectory:
 
  $ rsync -a /selected/download/folder/''YYYY_MM_DD_HH_MM_SS''/ matlab
or
* Then package the directory into a tarball:
 
  $ tar -cvf matlab.tar matlab
cd /tmp
* Download your licence:Go to [https://mathworks.com/mwaccount/ your MathWorks account] and click on the licence number you want to use. Then, go to the ''Install and activate'' tab and select ''Activate to retrieve licence File''. Follow the instructions and download the licence file needed for the installation. Name the file {{ic|matlab.lic}} and place it in the AUR package directory. There will also be a File Installation Key (FIK) visible on the MathWorks website. Copy-paste it in a new file named {{ic|matlab.fik}} and save it next to {{ic|PKGBUILD}} just like you did with the {{ic|matlab.lic}}.
ls | grep tmw
* Now, you will create a pacman package. You can customize the modules you want the package to contain by modifying the {{ic|PKGBUILD}} or leave it at default:
 
{{hc|PKGBUILD|2=
Merge the downloaded files to the installer:
...
 
# Limit products to lower size, set this to true to do a partial install
  rsync -a /tmp/tmwXXXXXXXX/archives matlab
partialinstall=false
 
# Example list of products for a partial install; check README.md for details
Then package the installer to the required tarball:
products=(
 
  "MATLAB"
  tar -cvf matlab.tar -C matlab/ .
  #---MATLAB Product Family---#
 
  "Curve_Fitting_Toolbox"          # Math and Optimization
Then download the .lic file: Go in [https://mathworks.com/mwaccount/ your MathWorks account] and click on the license number you want to use. Then, go to the Install and Activate tab and select "Activate to Retrieve License File". Follow the instructions and download the license file needed for the installation and name the file <tt>matlab.lic</tt>. Also, the File Installation Key (FIK) is displayed: copy-paste it in a empty file and name it <tt>matlab.fik</tt>.  
  "Database_Toolbox"              # Database Access and Reporting
 
  "Deep_Learning_HDL_Toolbox"
Copy the above files to the folder containing the PKGBUILD file. Then, modify the PKGBUILD file to install the toolboxes you need. Then, run the installation:
  "Deep_Learning_Toolbox"
 
  "DSP_System_Toolbox"
makepkg -sri
  "Global_Optimization_Toolbox"
 
  "GPU_Coder"
For more details, refer to the PKGBUILD file.
  "MATLAB_Coder"                # Code Generation
  "MATLAB_Compiler"              # Application Deployement
  "MATLAB_Compiler_SDK"
  "Optimization_Toolbox"
  "Parallel_Computing_Toolbox"        # Parallel computing
  "Partial_Differential_Equation_Toolbox"
  "Reinforcement_Learning_Toolbox"
  "Statistics_and_Machine_Learning_Toolbox"  # AI, Data Science, Statistics
  "Symbolic_Math_Toolbox"
  "Text_Analytics_Toolbox"
  #---Application Products---#
  "Audio_Toolbox"
  "Bioinformatics_Toolbox"          # Computational Biology
  "Computer_Vision_Toolbox"
  "Image_Processing_Toolbox"          # Image Processing and Computer Vision
  "Signal_Processing_Toolbox"        # Signal Processing
  "Wavelet_Toolbox"
)
...
}}
* Finally, use {{ic|makepkg}} command to build and install the package:
$ makepkg -sri


== Configuration ==
== Configuration ==
Line 120: Line 155:
  $ matlab -nodesktop -nosplash -r "opengl info; exit" | grep Software
  $ matlab -nodesktop -nosplash -r "opengl info; exit" | grep Software


If "software rendering" is not "false", then there is a problem with your hardware acceleration. If this is the case make sure OpenGL is configured correctly on the system. This can be done with the {{ic|glxinfo}} program from the {{Pkg|mesa-demos}} package:
If "software rendering" is not "false", then there is a problem with your hardware acceleration. If this is the case make sure OpenGL is configured correctly on the system. This can be done with the {{ic|glxinfo}} program from the {{Pkg|mesa-utils}} package:


  $ glxinfo | grep "direct rendering"
  $ glxinfo | grep "direct rendering"
Line 127: Line 162:


If glxinfo works but not matlab, you can try to run:
If glxinfo works but not matlab, you can try to run:
  $ export LD_PRELOAD=/usr/lib/libstdc++.so; export LD_LIBRARY_PATH=/usr/lib/xorg/modules/dri/; matlab -nodesktop -nosplash -r "opengl info; exit" | grep Software
  $ export LD_PRELOAD=/usr/lib/libstdc++.so; export LD_LIBRARY_PATH=/usr/lib/xorg/modules/dri/; matlab -nodesktop -nosplash -r "opengl info; exit" | grep Software


Line 132: Line 168:


  export LD_PRELOAD=/usr/lib/libstdc++.so
  export LD_PRELOAD=/usr/lib/libstdc++.so
  export LD_LIBRARY_PATH=/usr/lib/xorg/modules/dri/
  export LD_LIBRARY_PATH=/usr/lib/dri/


If you experience a low-level graphics error, you can use a software implementation of OpenGL or use an older driver. According to [[Intel graphics#Old OpenGL Driver (i965)|this]] entry in the ArchWiki, in Mesa 20.0 the new Iris driver was promoted to be the default for Gen8+. You may disable it and revert to use the old i965 driver by setting the {{ic|1=MESA_LOADER_DRIVER_OVERRIDE=i965}} [[environment variable]] before starting Matlab or any OpenGL application. Alternatively, you can run Matlab with the following command:
After these changes, you may see low-level graphics errors in the MATLAB console such as:


  $ env MESA_LOADER_DRIVER_OVERRIDE=i965 matlab -desktop
  com.jogamp.opengl.GLException: X11GLXDrawableFactory - Could not initialize shared resources for X11GraphicsDevice[type .x11, connection :0, unitID 0, handle 0x0, owner false, ResourceToolkitLock[obj 0x76ddc7cd, isOwner false, <6876ff80, 5d5c50dc>[count 0, qsz 0, owner <NULL>]]]
    at jogamp.opengl.x11.glx.X11GLXDrawableFactory$SharedResourceImplementation.createSharedResource(X11GLXDrawableFactory.java:326)
    at jogamp.opengl.SharedResourceRunner.run(SharedResourceRunner.java:297)
    at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.NullPointerException
    at jogamp.opengl.GLContextImpl.makeCurrent(GLContextImpl.java:688)
    at jogamp.opengl.GLContextImpl.makeCurrent(GLContextImpl.java:580)
    at jogamp.opengl.x11.glx.X11GLXDrawableFactory$SharedResourceImplementation.createSharedResource(X11GLXDrawableFactory.java:297)
    ... 2 more


If it works, you can edit the Matlab launcher script to add:
In that case, create a file with the name 'java.opts' in the directory where MATLAB is executed (for example {{ic|/usr/local/MATLAB/R2020a/bin/glnxa64}}) with the following line:


  export MESA_LOADER_DRIVER_OVERRIDE=i965
{{hc|java.opts|2=
  -Djogl.disable.openglarbcontext=1
}}


=== Sound ===
=== Sound ===
Line 148: Line 194:
  $ matlab -nodesktop -nosplash -r "load handel; sound(y, Fs); pause(length(y)/Fs); exit" > /dev/null
  $ matlab -nodesktop -nosplash -r "load handel; sound(y, Fs); pause(length(y)/Fs); exit" > /dev/null


This should play an except from Handel's "Hallelujah Chorus." If this fails make sure [[ALSA]] is properly configured. This can be done with the {{ic|speaker-test}} program from the {{Pkg|alsa-utils}} package from the [[official repositories]]:
This should play an except from Handel's "Hallelujah Chorus." If this fails make sure [[ALSA]] is properly configured. This can be done with the {{ic|speaker-test}} program from the {{Pkg|alsa-utils}} package:


  $ speaker-test
  $ speaker-test
Line 156: Line 202:
=== GPU computing ===
=== GPU computing ===


MATLAB can take advantage of [http://www.mathworks.co.uk/discovery/matlab-gpu.html CUDA enabled GPUs] to speed up applications. In order to take advantage of a supported GPU install the {{Pkg|nvidia}}, {{Pkg|nvidia-utils}}, {{Pkg|ocl-icd}}, {{Pkg|opencl-nvidia}}, and {{Pkg|cuda}} packages from the [[official repositories]]. To check if MATLAB is able to utilize the GPU run:
MATLAB can take advantage of [https://www.mathworks.co.uk/discovery/matlab-gpu.html CUDA enabled GPUs] to speed up applications. In order to take advantage of a supported GPU install the {{Pkg|nvidia}}, {{Pkg|nvidia-utils}}, {{Pkg|ocl-icd}}, {{Pkg|opencl-nvidia}}, and {{Pkg|cuda}} packages. To check if MATLAB is able to utilize the GPU run:


  $ matlab -nodesktop -nosplash -r "x=rand(10, 'single'); g=gpuArray(x); Success=isequal(gather(g), x), exit"  | sed -ne '/Success =/,$p'
  $ matlab -nodesktop -nosplash -r "x=rand(10, 'single'); g=gpuArray(x); Success=isequal(gather(g), x), exit"  | sed -ne '/Success =/,$p'
Line 162: Line 208:
=== Install supported compilers ===
=== Install supported compilers ===


In order to access the full functionality of MATLAB (e.g., to use Simulink, Builder JA, and MEX-file compilation), supported versions of the {{ic|gcc}}, {{ic|g++}}, {{ic|gfortran}}, and {{ic|jdk}} compilers must be installed. Details about the supported compilers for the [https://www.mathworks.com/support/compilers.html current release] and [https://www.mathworks.com/support/sysreq/previous_releases.html previous releases] are available online. Many of the supported {{ic|gcc}}, {{ic|g++}}, {{ic|jdk}} compiler versions for past MATLAB releases are available from the [[AUR]] (e.g., {{AUR|gcc43}}, {{AUR|gcc44}}, {{AUR|gcc47}}, {{AUR|gcc49}}and {{AUR|jdk6}}), while past versions of the {{ic|gfortran}} compilers are not packaged.
In order to access the full functionality of MATLAB (e.g., to use Simulink, Builder JA, and MEX-file compilation), supported versions of the {{ic|gcc}}, {{ic|g++}}, {{ic|gfortran}}, and {{ic|jdk}} compilers must be installed. Details about the supported compilers for the [https://www.mathworks.com/support/compilers.html current release] and [https://www.mathworks.com/support/sysreq/previous_releases.html previous releases] are available online. Many of the supported {{ic|gcc}}, {{ic|g++}}, {{ic|jdk}} compiler versions for past MATLAB releases are available from the [[AUR]] (e.g., {{AUR|gcc43}}, {{AUR|gcc44}}, {{AUR|gcc47}}, {{AUR|gcc49}}and {{AUR|jdk7}}), while past versions of the {{ic|gfortran}} compilers are not packaged.


To use previous versions of the the {{ic|gcc}}, {{ic|g++}}, and {{ic|gfortran}} compilers with MEX files, edit {{ic|${MATLAB}/bin/mexopts.sh}} and replace all occurrences of {{ic|<nowiki>CC='gcc'</nowiki>}} with {{ic|<nowiki>CC='gcc-4.X'</nowiki>}}, {{ic|<nowiki>CXX='g++'</nowiki>}} with {{ic|<nowiki>CXX='g++-4.X'</nowiki>}}, and {{ic|<nowiki>FC='gfortran'</nowiki>}} with {{ic|<nowiki>FC='gfortran-4.X'</nowiki>}}, where {{ic|X}} is the compiler version appropriate for the particular MATLAB release.
To use previous versions of the {{ic|gcc}}, {{ic|g++}}, and {{ic|gfortran}} compilers with MEX files, edit {{ic|${MATLAB}/bin/mexopts.sh}} and replace all occurrences of {{ic|<nowiki>CC='gcc'</nowiki>}} with {{ic|<nowiki>CC='gcc-4.X'</nowiki>}}, {{ic|<nowiki>CXX='g++'</nowiki>}} with {{ic|<nowiki>CXX='g++-4.X'</nowiki>}}, and {{ic|<nowiki>FC='gfortran'</nowiki>}} with {{ic|<nowiki>FC='gfortran-4.X'</nowiki>}}, where {{ic|X}} is the compiler version appropriate for the particular MATLAB release.


{{Note|Newer versions of Matlab (at least 2017a) doesn't seem to respect the {{ic|${MATLAB}/bin/mexopts.sh}} customization. Instead it uses {{ic|${MATLAB}/bin/glnxa64/mexopts/LANG_glnxa64.xml}} file.}}
{{Note|
 
* Newer versions of Matlab (at least 2017a) does not seem to respect the {{ic|${MATLAB}/bin/mexopts.sh}} customization. Instead it uses {{ic|${MATLAB}/bin/glnxa64/mexopts/LANG_glnxa64.xml}} file.
{{Note|Though, it's no officially supported, one could still use higher version of compiler, and ignore the warnings.}}
* Though, it is not officially supported, one could still use higher version of compiler, and ignore the warnings.
}}


=== Help browser ===
=== Help browser ===
Line 179: Line 226:


  >> webutils.htmlrenderer('default');
  >> webutils.htmlrenderer('default');
=== Garbled Interface ===
export J2D_D3D=false
export MATLAB_JAVA=/usr/lib/jvm/java-7-openjdk/jre


=== Serial port access ===
=== Serial port access ===


Matlab uses a bundled rxtx library to access serial ports. The built-in version requires the user to have write access directly to /var/run which is no good idea. The easiest way to fix this properly is to install the {{Pkg|java-rxtx}} package first. Follow the instructions shown while installing this package to get your user into the right groups. Then run the following commands to make Matlab use the system rxtx version:
To successfully connect to any serial port, MATLAB expects to have write access directly to {{ic|/var/lock}} which is not allowed on Arch Linux for security reasons. Instead of allowing this access just for MATLAB, you can work around this problem by redirecting device locking using {{AUR|lockdev-redirect}}. All you have to do is executing MATLAB like this:


  cd {MATLAB}/java/jarext
  # lockdev-redirect /{MATLAB}/bin/matlab
mv RXTXcomm.jar RXTXcomm.jar.off
ln -s /usr/share/java/rxtx/RXTXcomm.jar .
cd {MATLAB}/bin/glnx64
mv librxtxSerial.so librxtxSerial.so.off
ln -s /usr/lib/librxtxSerial.so .


If you have created a .desktop file as shortcut to MATLAB, then add "lockdev-redirect" as a prefix to your "Exec=" entry.


=== HiDPI and 4k ===
=== HiDPI and 4k ===


See [[HiDPI#MATLAB]]
See [[HiDPI#MATLAB]].


== Troubleshooting ==


== Troubleshooting ==
=== Warning: Initializing MATLAB Graphics failed ===


This error seems to happen on multi-monitor setups, see [https://www.mathworks.com/matlabcentral/answers/611786-warning-initializing-matlab-graphics-failed#comment_1131148 this forum post].


=== Blackscreen in help browser and livescripts ===
=== Blackscreen in help browser and livescripts ===


In order to use help browser and livescripts install {{aur|libselinux}}.
In order to use help browser and livescripts install {{aur|libselinux}}.


=== Static TLS errors ===
=== Static TLS errors ===
Line 223: Line 261:
is related to the bugs:
is related to the bugs:


* [http://www.mathworks.de/support/bugreports/961964 961964] for which patched libraries are available from [http://www.mathworks.de/support/bugreports/license/accept_license/5730?fname=attachment_961964_12b_13a_13b_14a_glnxa64_2014-01-30.zip&geck_id=961964 MathWorks]{{Dead link|2020|03|30|status=404}}
* [https://www.mathworks.de/support/bugreports/961964 961964] for which patched libraries are available from [http://www.mathworks.de/support/bugreports/license/accept_license/5730?fname=attachment_961964_12b_13a_13b_14a_glnxa64_2014-01-30.zip&geck_id=961964 MathWorks]{{Dead link|2020|03|30|status=404}}
* [http://www.mathworks.com/support/bugreports/1003952 1003952] for which workarounds exist
* [https://www.mathworks.com/support/bugreports/1003952 1003952] for which workarounds exist


A more general solution of recompiling {{ic|glibc}} has also been suggested. [https://stackoverflow.com/a/19468365/2787723]
A more general solution of recompiling {{ic|glibc}} has also been suggested. [https://stackoverflow.com/a/19468365]
 
=== MATLAB crashes when displaying graphics ===
 
To identify this error, start MATLAB with
 
LIBGL_DEBUG=verbose matlab
 
from the terminal and try to collect OpenGL information with {{ic|opengl info}} from the MATLAB command prompt. If it crashes again and there is an output line like
 
libGL error: dlopen /usr/lib/xorg/modules/dri/swrast_dri.so failed
(/usr/local/MATLAB/R2011b/bin/glnxa64/../../sys/os/glnxa64/libstdc++.so.6:
version `GLIBCXX_3.4.15' not found (required by /usr/lib/xorg/modules/dri/swrast_dri.so))
 
then the problem is that MATLAB uses its own GNU C++ library, which is an older version than the up-to-date version on your Archlinux system. Make MATLAB use the current C++ library for your system by
 
cd /usr/local/MATLAB/R(your release)/sys/os/glnxa64
sudo unlink libstdc++.so.6
sudo ln -s /usr/lib/libstdc++.so.6
 
If MATLAB still crashes or corrupts graphics (during startup or when plotting), make sure Java's 2D OpenGL rendering is disabled.
The environment variable {{ic|_JAVA_OPTIONS}} should not contain {{ic|1=-Dsun.java2d.opengl=true}}.


=== Blank/grey UI when using WM (non-reparenting window manager) ===
=== Blank/grey UI when using WM (non-reparenting window manager) ===


This is a common issue in a number of window managers. (DWM, Awesome, bspwm) Java does not play well with these window managers. There are two methods.
See [[Java#Gray window, applications not resizing with WM, menus immediately closing]].


First try setting the environment variable by running
=== Corrupted text and fonts in menus and fields ===
 
$ export _JAVA_AWT_WM_NONREPARENTING=1


If Matlab works afterwards, export the variable in your {{ic|.xinitrc}}.
If it doesn't resolve, you have to fool Java into thinking the WM is named LG3D. (It's an old, depreciated WM that Java applications ironically support) Clean the previous environment variable, install the {{Pkg|wmname}} utility, and run.
wmname LG3D
Try running Matlab. If it works, put the fix in your starting script. ({{ic|.xinitrc}}, {{ic|bspwmrc}} and similar should be OK) Do note that other applications (such as {{ic|neofetch}}, or {{ic|tdrop}}) will think your WM is named LG3D, so you will have to configure them accordingly. Another solution is to run the command only before launching Matlab, and fixing the name after you are done with Matlab.
If it doesn't work, try the combination of both. (The second line works in bspwm) If it still doesn't work, try googling similar issues with java in general.
=== Garbled or invisible text ===
Set the environment variable <code>J2D_D3D</code> to <code>false</code>[https://stackoverflow.com/questions/22737535/swing-rendering-appears-broken-in-jdk-1-8-correct-in-jdk-1-7].
In newer versions of MATLAB (R2015b) [https://www.reddit.com/r/archlinux/comments/3yaga8/matlab_installer_bonked/] this also requires setting <code>MATLAB_JAVA</code> to something openjdk based. Example:
export J2D_D3D=false
./bin/glnxa64/install_unix -javadir /usr/lib/jvm/java-7-openjdk/jre
=== Corrupted text and fonts in menus and fields ===
If you notice that the menus or the input fields are corrupted or not appearing correctly then you can try to activate the ''"'''Use antialiasing to smooth desktop fonts'''"'' option in Matlab preferences, it seems to solve the problem. Go to '''''Preferences -> Matlab -> Fonts''''' and activate it. You will need to restart Matlab in order to take affect.
If you notice that the menus or the input fields are corrupted or not appearing correctly then you can try to activate the ''"'''Use antialiasing to smooth desktop fonts'''"'' option in Matlab preferences, it seems to solve the problem. Go to '''''Preferences -> Matlab -> Fonts''''' and activate it. You will need to restart Matlab in order to take affect.


=== Installation dependencies missing ===
=== Installation dependencies missing ===
Matlab might complain that it cannot find a package. Look at the package name and install it with [[Pacman]], or in the case of x86_64 there are some libraries only in [[AUR]]. {{AUR|matlab}} and {{AUR|matlab-dummy}} packages contain a list of up-to-date dependencies for the newest Matlab version.


If you get the following error when running the install script:
Matlab might complain that it cannot find a package. Look at the package name and install it with [[Pacman]], or in the case of x86_64 there are some libraries only in [[AUR]]. {{AUR|matlab}} and {{AUR|matlab-dummy}}{{Broken package link|package not found}} packages contain a list of up-to-date dependencies for the newest Matlab version.


terminate called after throwing an instance of 'std::runtime_error'
See also [[#Unable to launch the MATLABWindow application]].
  what():  Unable to launch the MATLABWindow application
Aborted


this is solved by installing {{AUR|libselinux}} from the AUR.
=== Installation error: archive is not a ZIP archive ===


=== Installation error: archive is not a ZIP archive ===
During the installation you can get:
During the installation you can get:


Line 301: Line 292:


=== Install-time library errors ===
=== Install-time library errors ===
* Make sure that the symlink {{ic|bin/glnx64/libstdc++.so.6}} is pointing to the correct version of {{ic|libstdc++.so.xx}} (which is also in the same directory and has numbers where 'xx' is). By default, it may be pointing to an older (and nonexistent) version (different value for 'xx').
* Make sure that the symlink {{ic|bin/glnx64/libstdc++.so.6}} is pointing to the correct version of {{ic|libstdc++.so.xx}} (which is also in the same directory and has numbers where 'xx' is). By default, it may be pointing to an older (and nonexistent) version (different value for 'xx').


* Make sure the device you're installing from is not mounted as {{ic|noexec}}
* Make sure the device you are installing from is not mounted as {{ic|noexec}}


* If you downloaded the files from Mathworks' website, make sure they are not on an NTFS or FAT partition, because that can mess up the symlinks. Ext4 or Ext3 should work.
* If you downloaded the files from Mathworks' website, make sure they are not on an NTFS or FAT partition, because that can mess up the symlinks. Ext4 or Ext3 should work.
=== Resolving start warnings/errors ===
* Even if all needed libraries are installed, Matlab when starting can still report some missing libraries. This is resolved by symbolic linking of needed libraries to directories that Matlab checks at start-up. For example, if Matlab triggers error/warning about missing {{ic|/lib64/libc.so.6}} library, this can be resolved by:
# ln -s /lib/libc.so.6 /lib64
* Matlab R2011b with an up-to-date Arch Linux (as of March 12, 2012) fails on startup with the familiar "Failure loading desktop class." A solution is to point Matlab to the system JVM (confirmed to work with the {{Pkg|jdk7-openjdk}} package):
export MATLAB_JAVA=/usr/lib/jvm/java-7-openjdk/jre
* Matlab R2017b with an up-to-date Arch Linux (as of September 30, 2017) fails on startup with the familiar "Failure loading desktop class." A solution is to install outdated versions of the libraries in the packages {{Pkg|cairo}} (1.14.10 works) and {{Pkg|harfbuzz}} (1.4.6 works) to a local directory and add them to the LD_LIBRARY_PATH for matlab (See also: [https://bbs.archlinux.org/viewtopic.php?id=228944]):
LD_LIBRARY_PATH="/opt/matlab/outdatedLibraries/:$LD_LIBRARY_PATH" /opt/matlab/R2017b/bin/matlab
=== Segmentation fault on startup ===
If Matlab (R2016a or earlier) stops working after upgrading {{Pkg|ncurses}} to v6.x, [[install]] the {{AUR|ncurses5-compat-libs}} package. See [https://bbs.archlinux.org/viewtopic.php?id=202575 BBS#202575].
In newer versions (e.g. R2017b), the issue could also be due to a font display failing to load.
Try moving the libfreetype.so.6 font display file in $MATLAB/bin/glnxa64/ to an 'exclude' directory; see [https://bbs.archlinux.org/viewtopic.php?id=231299 BBS#231299].
ncurses compatibility layer is not required anymore for R2018a.


=== Hangs on rendering or exiting with Intel graphics ===
=== Hangs on rendering or exiting with Intel graphics ===
Line 342: Line 311:
See [https://bugzilla.redhat.com/show_bug.cgi?id=1357571] and [https://bugs.freedesktop.org/show_bug.cgi?id=96671] for more.
See [https://bugzilla.redhat.com/show_bug.cgi?id=1357571] and [https://bugs.freedesktop.org/show_bug.cgi?id=96671] for more.


=== Addon manager not working ===
=== LiveScript errors ===
This section is relevant for both R2017b and R2018a.
 
Addon manager requires the {{AUR|libselinux}} package to work.
 
Since upgrade from pango-1.40.5 to pango-1.40.6, the MATLABWindow application (responsible for Add-On Manager, Simulation Data Inspector and perhaps something else) cannot be started. {{Bug|54257}}
A workaround is to point MATLAB shipping glib libraries to those glib libraries from your system. There are 5 of those libraries in {{ic|matlabroot/R2017b/cefclient/sys/os/glnxa64}}, namely, as of R2017b:


libgio-2.0.so
libglib-2.0.so
libgmodule-2.0.so
libgobject-2.0.so
libgthread-2.0.so
Make it so that these symlinks are pointing to your system glib libraries instead of versions located in {{ic|matlabroot/R2017b/cefclient/sys/os/glnxa64}}.
On a standard arch install the local files reside in {{ic|/usr/lib/}}.
Do not forget to update the {{ic|*.0}} links as well.
Relinking of "libfreetype.so.6" is also necessary to open these interfaces. This is found in {{ic|matlabroot/R2017b/bin/glnxa64/}}.
If the window opens but is blank, consider switching the html renderer to: " webutils.htmlrenderer('basic');" as described in [[#Help browser]].
=== Live Script Errors ===
If you get the error when attempting to load or create a LiveScript:
If you get the error when attempting to load or create a LiveScript:
   {{ic|Viewing matlab live script files is not currently supported by this operating system configuration}}
   {{ic|Viewing matlab live script files is not currently supported by this operating system configuration}}
*It could be because of broken symlinks of {{Pkg|libgcrypt}} and other dependencies, after system updates. On the first start of the Live Editor the components are extracted and these libary symlinks are created (if not existing).
*It could be because of broken symlinks of {{Pkg|libgcrypt}} and other dependencies, after system updates. On the first start of the Live Editor the components are extracted and these libary symlinks are created (if not existing).
 
: A solution is to simply delete the whole folder containing the broken symlinks and the extracted components, which are in the installation directory:
A solution is to simply delete the whole folder containing the broken symlinks and the extracted components, which are in the installation directory (represented by {{ic|$MATLABROOT}}) under:
  ''matlab_root''/sys/jxbrowser-chromium
  $MATLABROOT/sys/jxbrowser-chromium
: Or, if the installation directory is not user writable, then in:
Or if the installation directory is not user writable in:
  ~/.matlab/R2017b/HtmlPanel
  ~/.matlab/R2017b/HtmlPanel
Matlab will then regenerate the contents on the next Live Editor start.
: Matlab will then regenerate the contents on the next Live Editor start.
 
: A better option is to replace libgcrypt symlink in this extraction directory with a less precise one. For example, after extraction, this link to /lib64/libgcrypt.so.20.2.4 is created. Replace it with e.g. /lib64/libgcrypt.so.20.
A better option is to replace libgcrypt symlink in this extraction directory with a less precise one. For example, after extraction, this link to /lib64/libgcrypt.so.20.2.4 is created. Replace it with e.g. /lib64/libgcrypt.so.20.
: Matlab R2020 does not contain a chromium directory anymore. Relinking the library file libcrypto.so.1.1 with the system file can resolve the issue. It is located in:
*Also the steps in [[#Addon manager not working]] may resolve the issue.
''matlab_root''/bin/glnxa64
*Also the steps in [[#Unable to launch the MATLABWindow application]] may resolve the issue.
*It can also happen due to missing gconf package. Make sure {{AUR|gconf}} is installed.
*It can also happen due to missing gconf package. Make sure {{AUR|gconf}} is installed.
*If the above does not help, execute in the command window
*If the above does not help, execute in the command window
Line 386: Line 333:


=== Using webcam/video device ===
=== Using webcam/video device ===
Make sure the correct support package addons are installed (webcam or OS Generic Video Interface for example). If running matlab as a user, make sure your user has write permissions to wherever the support packages are being downloaded and installed.


At least Matlab 2016b doesn't recognize webcams or imaq adapters correctly without gstreamer0.10. The gstreamer0.10 can be found in the aur and installed as a work around.
Make sure the correct support package add-ons are installed (webcam or OS Generic Video Interface for example). If running matlab as a user, make sure your user has write permissions to wherever the support packages are being downloaded and installed.


Since MATLAB R2017a, Image Acqusition Toolbox is using GStreamer library version 1.0. It previously used version 0.10.
Since MATLAB R2017a, Image Acqusition Toolbox is using GStreamer library version 1.0. It previously used version 0.10.
Line 394: Line 340:
In general, USB Webcam Support Package does a better job working with UVC and built-in cameras than OS Generic Video Interface Support Package.
In general, USB Webcam Support Package does a better job working with UVC and built-in cameras than OS Generic Video Interface Support Package.


{{Warning|As of 2018-08-15 updating gst from 1.14.0 to 1.14.2 breaks video device operation (MATLAB doesn't see the video device anymore). Downgrading fixes this.}}
=== MATLAB hangs for several minutes when closing Help Browser ===
 
{{Style|Written in first person}}


=== MATLAB hangs for several minutes when closing Help Browser ===
Since upgrade of glibc from 2.24 to 2.25, MATLAB (at least R2017a) hangs when closing Help Browser. The issue is related to the particular version of jxbrowser-chromium shipped with MATLAB.
Since upgrade of glibc from 2.24 to 2.25, MATLAB (at least R2017a) hangs when closing Help Browser. The issue is related to the particular version of jxbrowser-chromium shipped with MATLAB.
This issue is still present with glibc 2.26 and MATLAB R2017b and R2018a.
This issue is still present with glibc 2.26 and MATLAB R2017b and R2018a.
Line 402: Line 349:
To fix this issue, download the [https://www.teamdev.com/jxbrowser latest jxbrowser] and replace the following jars from MATLAB:
To fix this issue, download the [https://www.teamdev.com/jxbrowser latest jxbrowser] and replace the following jars from MATLAB:


  matlabroot/java/jarext/jxbrowser-chromium/jxbrowser-chromium.jar
  ''matlab_root''/java/jarext/jxbrowser-chromium/jxbrowser-chromium.jar
  matlabroot/java/jarext/jxbrowser-chromium/jxbrowser-linux64.jar
  ''matlab_root''/java/jarext/jxbrowser-chromium/jxbrowser-linux64.jar


MATLAB should automatically unpack those jars into {{ic|matlabroot/sys/jxbrowser-chromium/glnxa64/chromium}} when first opening Help Browser.
MATLAB should automatically unpack those jars into {{ic|''matlab_root''/sys/jxbrowser-chromium/glnxa64/chromium}} when first opening Help Browser.
Remove {{ic|matlabroot/sys/jxbrowser-chromium/glnxa64/chromium}} directory to make sure MATLAB uses the latest jxbrowser.
Remove {{ic|''matlab_root''/sys/jxbrowser-chromium/glnxa64/chromium}} directory to make sure MATLAB uses the latest jxbrowser.


Unfortunately, this workaround doesn't work in R2017b anymore. Going deeper into investigation of this issue, it is related to a crash of one of jxbrowser-chromium processes. The parent process of jxbrowser-chromium then sits there and waits for response from a process that is already dead. This causes MATLAB main window to freeze. You can easily unfreeze MATLAB by manually killing all leftover jxbrowser-chromium processes.
Unfortunately, this workaround does not work in R2017b anymore. Going deeper into investigation of this issue, it is related to a crash of one of jxbrowser-chromium processes. The parent process of jxbrowser-chromium then sits there and waits for response from a process that is already dead. This causes MATLAB main window to freeze. You can easily unfreeze MATLAB by manually killing all leftover jxbrowser-chromium processes.


I've come up with this simple script that uses inotify and waits for user to close Help browser in MATLAB. It triggers when user closes Help browser and sends kill signal to all leftover jxbrowser-chromium processes:
I have come up with this simple script that uses inotify and waits for user to close Help browser in MATLAB. It triggers when user closes Help browser and sends kill signal to all leftover jxbrowser-chromium processes:


#!/usr/bin/bash
{{bc|1=
#!/bin/sh
if [ -z "$1" ]; then
 
REL=R2017b
if [ -z "$1" ]; then
else
REL=R2017b
REL=$1
else
fi
REL=$1
fi
JXPATH="/path/to/MATLAB/$REL/sys/jxbrowser-chromium/glnxa64/chromium"
 
CMD="inotifywait -m -e CLOSE $JXPATH/resources.pak"
JXPATH="/path/to/MATLAB/$REL/sys/jxbrowser-chromium/glnxa64/chromium"
CMD="inotifywait -m -e CLOSE $JXPATH/resources.pak"
#Exit if the daemon is already active
 
if ! pgrep -f "$CMD" > /dev/null; then
#Exit if the daemon is already active
#Wait for user to close Help Browser, then killall leftover jxbrowser processes
if ! pgrep -f "$CMD" > /dev/null; then
$CMD |
#Wait for user to close Help Browser, then killall leftover jxbrowser processes
while read line
$CMD {{!}}
do
while read line
killall "$JXPATH/jxbrowser-chromium"
do
done
killall "$JXPATH/jxbrowser-chromium"
else
done
exit
else
fi
exit
fi
}}


I run this script as part of my MATLAB start script like that:
I run this script as part of my MATLAB start script like that:
Line 442: Line 391:


=== Some dropdown menus cannot be selected ===
=== Some dropdown menus cannot be selected ===
In some interfaces - such as Simulation Data Inspector or Simulink Test Manager - nothing happens when choosing an item in dropdown menu (for example, when trying to change a number of subplots in Simulation Data Inspector). To work around this issue, hold down the Shift key while clicking the item in dropdown menu.
In some interfaces - such as Simulation Data Inspector or Simulink Test Manager - nothing happens when choosing an item in dropdown menu (for example, when trying to change a number of subplots in Simulation Data Inspector). To work around this issue, hold down the Shift key while clicking the item in dropdown menu.


=== Not starting - licensing error===
=== Not starting - licensing error ===
 
In case MATLAB will not start from a [[desktop environment]] by the call of its [[desktop file]] one should see the output as you start it from the terminal.
In case MATLAB will not start from a [[desktop environment]] by the call of its [[desktop file]] one should see the output as you start it from the terminal.


For a ''Licensing error'' such as:
For a ''Licensing error'' such as:


{{hc
{{hc|# matlab|<nowiki>
|# matlab|
MATLAB is selecting SOFTWARE OPENGL rendering.
MATLAB is selecting SOFTWARE OPENGL rendering.
License checkout failed.
License checkout failed.
Line 460: Line 410:


Troubleshoot this issue by visiting:  
Troubleshoot this issue by visiting:  
http://www.mathworks.com/support/lme/R2017a/9
https://www.mathworks.com/support/lme/R2017a/9


Diagnostic Information:
Diagnostic Information:
Line 468: Line 418:
.lic  
.lic  
Licensing error: -9,57.
Licensing error: -9,57.
}}
</nowiki>}}


A re-activation might solve the problem.
A re-activation might solve the problem.
/usr/local/MATLAB/R2017a/bin/activate_matlab.sh -javadir /usr/lib/jvm/java-8-openjdk/jre/


=== MATLAB crashes with "Failure loading desktop class" on startup ===
=== MATLAB crashes with "Failure loading desktop class" on startup ===
In case MATLAB won't start and starting it from command line gives you the following error:
 
In case MATLAB will not start and starting it from command line gives you the following error:
{{hc
{{hc
|$ matlab|
|$ matlab|
Fatal Internal Error: Internal Error: Failure occurs during desktop startup. Details: Failure loading desktop class.
Fatal Internal Error: Internal Error: Failure occurs during desktop startup. Details: Failure loading desktop class.
}}
}}
and you have the option [[Java#GTK_LookAndFeel|{{ic|1=-Dswing.defaultlaf=com.sun.java.swing.plaf.gtk.GTKLookAndFeel}}]] set in your {{ic|_JAVA_OPTIONS}} environment variable, start MATLAB with
and you have the option [[Java#GTK LookAndFeel|-Dswing.defaultlaf=com.sun.java.swing.plaf.gtk.GTKLookAndFeel]] set in your {{ic|_JAVA_OPTIONS}} environment variable, start MATLAB with


  $ _JAVA_OPTIONS= matlab
  $ _JAVA_OPTIONS= matlab
Line 489: Line 442:


=== Unable to type in text fields of interfaces based on MATLABWindow ===
=== Unable to type in text fields of interfaces based on MATLABWindow ===
{{Style|Written in first person}}
Since R2018a, it is not possible to type text in interfaces based on MATLABWindow - like Signal Editor, Add-Ons Explorer and others.
Since R2018a, it is not possible to type text in interfaces based on MATLABWindow - like Signal Editor, Add-Ons Explorer and others.
MATLABWindow and MATLAB's webwindow infrastructure is based on Chromium Embedded Framework, and it looks like a known and long standing bug: https://bitbucket.org/chromiumembedded/cef/issues/2026/multiple-major-keyboard-focus-issues-on
MATLABWindow and MATLAB's webwindow infrastructure is based on Chromium Embedded Framework, and it looks like a known and long standing bug: https://bitbucket.org/chromiumembedded/cef/issues/2026/multiple-major-keyboard-focus-issues-on
Line 503: Line 458:
Now, whenever it is not possible to type in a text field, I press Alt+Mouse middle mouse and then I can type again.
Now, whenever it is not possible to type in a text field, I press Alt+Mouse middle mouse and then I can type again.


=== Installer crashes with "Unable to launch the MATLABWindow application" ===
This problem is critical during installation.  After one clicks some elements in the installation window, he will not be able to type into any textbox anymore and switching between windows does not always work.  To circumvent the issue, one shall only use key-press, instead of mouse click during installation.  MATLAB installer has a poor support on Wayland, one may also consider using other WM instead during installation.
In MATLAB version R2020a Update 5 (and possibly older), the installer crashes before the splash in shown.
 
=== Unable to launch the MATLABWindow application ===
 
In MATLAB versions R2018b until R2022b, the installer crashes as follows:
 
{{hc
| $ ./install |
terminate called after throwing an instance of 'std::runtime_error'
  what():  Failed to launch web window with error: Unable to launch the MATLABWindow application. The exit code was: 127
[1]    1409378 IOT instruction (core dumped)  ./install
}}
 
To find out why {{ic|MATLABWindow}} is crashing, run it manually to get detailed information.
 
{{hc
{{hc
|$ ./install |
| $ ./bin/glnxa64/MATLABWindow |
terminate called after throwing an instance of 'std::runtime_error'
bin/glnxa64/MATLABWindow: symbol lookup error: /usr/lib/libcairo.so.2: undefined symbol: FT_Get_Color_Glyph_Layer
  what(): Unable to launch the MATLABWindow application
Aborted (core dumped)
}}
}}


The problem is solved by removing (or hiding) the {{ic|libgl*}} libraries of the MATLAB installer, as suggested for an older issue [https://it.mathworks.com/matlabcentral/answers/397138-why-do-i-get-a-matlabwindow-application-failed-to-launch-error-when-launching-live-editor-app-des#answer_316968]
{{ic|FT_Get_Color_Glyph_Layer}} is a symbol of {{Pkg|freetype2}}, which indicates a library incompatibility between the MATLAB application and the Arch Linux packages. [https://ww2.mathworks.cn/matlabcentral/answers/364551-why-is-matlab-unable-to-run-the-matlabwindow-application-on-linux]
$ cd matlab_R2020a_glnxa64/cefclient/sys/os/glnxa64/
$ mkdir exclude
$ mv libglib-2.0.so* exclude/


=== Add-on manager does not start in R2020a ===
To fix this, put aside MATLAB's {{ic|libfreetype.so*}}.


In MATLAB version R2020a Update 5 (and possibly older), the Add-on manager does not start. Instead, the following error is shown
$ rm ./bin/glnxa64/libfreetype.so*


  Error using matlab.internal.cef.webwindow (line 385)
You can also use {{ic|LD_PRELOAD}} environment variable to force MATLAB use Arch Linux's libfreetype without removing the lib file.
  MATLABWindow application failed to launch. Unable to launch the MATLABWindow application
 
  Error in matlab.internal.webwindow/createImplementation (line 288)
                  implObj = matlab.internal.cef.webwindow(varargin{:});
 
  Error in matlab.internal.webwindow (line 144)
              obj.impl = obj.createImplementation(varargin{:});
 
  Error in matlab.internal.addons.AddOnsWindow/launch (line 51)
                  obj.webwindow = matlab.internal.webwindow(char(url), obj.debugPort, obj.normalWindowPosition);
 
  Error in matlab.internal.addons.Explorer/loadUrlForNavigateToMessage (line 125)
                  obj.addOnsWindowInstance.launch(url, obj.windowStateUtil.getExplorerWindowMaximizedSetting);
 
  Error in matlab.internal.addons.Explorer/show (line 56)
                  obj.loadUrlForNavigateToMessage(url);
 
  Error in matlab.internal.addons.launchers.showExplorer (line 128)
          matlab.internal.addons.Explorer.getInstance.show(navigationData);


The problem is solved by removing (or hiding) the {{ic|libgl*}} and {{ic|libgio*}} libraries of MATLAB, as suggested for an older issue [https://it.mathworks.com/matlabcentral/answers/397138-why-do-i-get-a-matlabwindow-application-failed-to-launch-error-when-launching-live-editor-app-des#answer_316968]
  $ export LD_PRELOAD=/lib64/libfreetype.so
  $ ./install
  $ cd {MATLAB INSALLATION FOLDER}/cefclient/sys/os/glnxa64/
  $ mkdir exclude
$ mv libglib-2.0.so* libgio-2.0.so* exclude/


== Matlab in a systemd-nspawn ==
Similarly, if the error is caused by {{ic|undefined symbol: g_log_structured...}}, put aside MATLAB's {{ic|libglib-2.0.so*}}. If the error is caused by {{ic|path to/libstdc++.so.6: version `CXXABI_1.3.9' not found (required by _somelibrary_)}}, put aside MATLAB's {{ic|libstdc++.so.6}}.
Matlab can be run within a systemd-nspawn container to maintain a static system and avoid the library issues that often plague matlab installs after significant updates to libraries in Arch. Refer to [[Systemd-nspawn]] for detailed information on setting up such containers.


The following lists instruction to get a MATLAB 2017b install running in a minimal debian 9 environment. It assumes matlab is already installed as normal in "/usr/local/MATLAB/R2017b".  
=== Cannot verify university login during installation ===
 
For total headcount license users, MATLAB will pop-up a window asking the user to login with their credentials in a web browser.  However, if run with {{ic|sudo}}, most browsers (especially chromium) will not run.  To circumvent this problem, one shall 'active the computer' through MATLAB's website using a browser by a normal user. [https://www.mathworks.com/matlabcentral/answers/326647-verify-university-login-not-open-browser See this issue]
 
=== Missing libcrypt.so.1 ===
 
If you get this error when launching or installing MATLAB (R2020a and later), install {{Pkg|libxcrypt-compat}}.
 
=== Running installer as root does not launch the GUI ===
 
If you run the installer as root and the GUI does not appear (but does appear without launching as root), try temporarily allowing the root user to access the X Server by running the following commands in order (where {{ic|./install}} is the command to run the installer as root):
 
$ xhost +SI:localuser:root
# ./install
$ xhost -SI:localuser:root
 
Note that the last command should be executed upon finishing the installation process, and {{ic|localuser}} is a string literal. See [https://au.mathworks.com/matlabcentral/answers/1461039-on-ubuntu-sudo-won-t-run-the-install-file#comment_1782671 this support answer], and {{man|1|xhost}}.
 
In addition, verify that the {{ic|DISPLAY}} environment variable is set.
 
An alternative is to install MATLAB as a local user.
 
=== GUI installer is unable to create the target folder when installing as user ===
 
Make the folder manually (as root), and take ownership. The path is typically /usr/local/MATLAB
# mkdir -p /path/to/MATLAB/R20XXx
# chown -R $LOGNAME: /path/to/MATLAB/R20XXx
 
=== MATLAB crashes when opening Simulink ===
 
When running from terminal the error message is:
 
Inconsistency detected by ld.so: ../elf/dl-tls.c: 597: _dl_allocate_tls_init: Assertion `listp != NULL' failed!
 
See upstream bug report here: https://www.mathworks.com/support/bugreports/details/2632298
 
=== MATLAB cannot open or create script files ===
 
See [[#Unable to launch the MATLABWindow application]].
 
=== Calls to mex fail ===
 
If calls from MATLAB or Simulink to mex (e.g. rapid accelerator) fail with the error {{ic|*.mexa64 is not a MEX file}}, even though the resulting file is usable, it may help to edit {{ic|}} in either {{ic|matlab/bin/}} or {{ic|~/.matlab7rc.sh}} by changing the {{ic|LDPATH_PREFIX}} variable from its empty default: [https://github.com/alecjacobson/matlab/blob/883d417a99fcb8ead89387cee243e51a92864019/bin/.matlab7rc.sh#L170]
 
{{hc|matlab/bin/.matlab7rc.sh (or ~/.matlab7rc.sh)|2=
...
    case "$ARCH" in
'''glnx*)''' #  Make sure you are modifying case '''glnx*'''
    AUTOMOUNT_MAP=<nowiki>''</nowiki>
    DISPLAY="$DISPLAY"
    ARCH="$ARCH"
    TOOLBOX="$TOOLBOX"
    MATLABPATH="$MATLABPATH"
    SHELL="$SHELL"
    '''LDPATH_PREFIX='/usr/lib' '''
...
}}
 
=== Incompatibilities with some python libraries using MKL ===
 
Some python code running inside matlab may fail with an error mentioning {{ic|Parameter * was incorrect on entry to }}. This can be avoided by calling
py.sys.setdlopenflags(int32(bitor(int64(py.os.RTLD_NOW), int64(py.os.RTLD_DEEPBIND))));
or
py.sys.setdlopenflags(int32(bitor(int64(py.os.RTLD_LAZY), int64(py.os.RTLD_DEEPBIND))));
directly before any calls to {{ic|py}} and after calls to {{ic|pyenv}}.
See [https://www.mathworks.com/matlabcentral/answers/358233-matlab-python-interface-broken?s_tid=email_ans_new_ans_ans_h#answer_283353 this support answer].
 
=== Settings not persisting between MATLAB restarts ===
 
In some cases on recent Arch systems matlab is unable to export {{ic|.mlsettings}} files, preventing toolbox and some matlab settings from being saved to disk and persisted. These cases come from matlab trying to hard link new files from {{ic|/tmp}} directly to the preferences directory (usually {{ic|~/.matlab/release}} where {{ic|release}} is the matlab version, e.g. {{ic|R2021b}}). As a workaround, run matlab with the {{ic|$TMPDIR}} environment variable set to a folder on the same file system as the preferences directory. [https://www.mathworks.com/matlabcentral/answers/1777865-matlab-preferences-not-being-saved-across-sessions]
 
=== "Unable to open this file in the current system configuration" ===
 
The error can be fixed by setting aside the l{{ic|ibfreetype.so.6}} in {{ic|''matlab_root''/bin/glnxa64/}}. You may run the following command:
 
cd ''matlab_root''/bin/glnxa64/
mv libfreetype.so.6 libfreetype.so.6.old
 
=== Symbols in toolstrip menus are not diplayed properly ===
 
{{Expansion|Explain which symbols are needed, so that users can choose any font providing them.}}
 
This issue can be fixed by [[install]]ing {{Pkg|noto-fonts}}.
 
=== Blank screen on Xwayland ===
As suggested in [[Wayland#Java]], this issue can be fixed by adding in the Matlab launcher script:
export _JAVA_AWT_WM_NONREPARENTING=1
 
=== Desktop Error with text not rendering ===
Launching MATLAB you get an error dialog with a message of "desktop error" and the text doesn't render.
The error log looks like this
 
{{
hc|ERROR|2=
Crash report:
Ajava.lang.ExceptionInInitializerError
at com.mathworks.mde.cmdwin.CmdWin.<init>(CmdWin.java:111)
at com.mathworks.mde.cmdwin.CmdWin.<clinit>(CmdWin.java:107)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:264)
at com.mathworks.jmi.ClassLoaderManager.loadClass(ClassLoaderManager.java:442)
at com.mathworks.jmi.ClassLoaderManager.findClass(ClassLoaderManager.java:422)
at com.mathworks.jmi.Matlab$2.findClass(Matlab.java:517)
at com.mathworks.util.ClassLoaderBridge.findClass(ClassLoaderBridge.java:23)
at com.mathworks.widgets.desk.DTClient.createComponent(DTClient.java:275)
at com.mathworks.widgets.desk.Desktop.createClientComponent(Desktop.java:6468)
at com.mathworks.mde.desk.MLDesktop.createClientComponent(MLDesktop.java:1040)
at com.mathworks.widgets.desk.Desktop.createClientComponentWrapper(Desktop.java:6482)
at com.mathworks.widgets.desk.Desktop.setClientShowing(Desktop.java:7181)
at com.mathworks.widgets.desk.Desktop.setClientShowing(Desktop.java:7168)
at com.mathworks.widgets.desk.DTNestingContainer$ViewState.restore(DTNestingContainer.java:2910)
at com.mathworks.widgets.desk.DTNestingContainer$SplitState.restore(DTNestingContainer.java:2536)
at com.mathworks.widgets.desk.DTNestingContainer$SplitState.restore(DTNestingContainer.java:2537)
at com.mathworks.widgets.desk.DTNestingContainer$RootState.restore(DTNestingContainer.java:2422)
at com.mathworks.widgets.desk.DTNestingContainer$RootState.restore(DTNestingContainer.java:2417)
at com.mathworks.widgets.desk.DTNestingContainer.restoreState(DTNestingContainer.java:2291)
at com.mathworks.widgets.desk.DTMultipleClientFrame.restoreState(DTMultipleClientFrame.java:2791)
at com.mathworks.widgets.desk.Desktop.restoreLayout(Desktop.java:5947)
at com.mathworks.mde.desk.MLDesktop.restoreLayout(MLDesktop.java:1652)
at com.mathworks.widgets.desk.Desktop.restoreLayout(Desktop.java:5706)
at com.mathworks.mde.desk.MLDesktop.setDefaultDesktop(MLDesktop.java:1539)
at com.mathworks.widgets.desk.Desktop.initMainFrame(Desktop.java:296)
at com.mathworks.mde.desk.MLDesktop.initMainFrameFromThread(MLDesktop.java:844)
at com.mathworks.mde.desk.MLDesktop.access$600(MLDesktop.java:224)
at com.mathworks.mde.desk.MLDesktop$Initializer.run(MLDesktop.java:1215)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:758)
at java.awt.EventQueue.access$500(EventQueue.java:97)
at java.awt.EventQueue$3.run(EventQueue.java:709)
at java.awt.EventQueue$3.run(EventQueue.java:703)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:74)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:728)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:205)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
Caused by: java.lang.ArithmeticException: / by zero
at com.mathworks.mde.cmdwin.XCmdWndView.getPotentialColumns(XCmdWndView.java:1072)
at com.mathworks.mde.cmdwin.XCmdWndView.setCWFont(XCmdWndView.java:1651)
at com.mathworks.mde.cmdwin.XCmdWndView.initPrefs(XCmdWndView.java:907)
at com.mathworks.mde.cmdwin.XCmdWndView.<init>(XCmdWndView.java:401)
at com.mathworks.mde.cmdwin.XCmdWndView.<clinit>(XCmdWndView.java:329)
... 43 more
}}
 
The error is related to missing fonts and can be fixed installing from the AUR the package ttf-ms-fonts
 
== MATLAB in a systemd-nspawn ==
 
MATLAB can be run within a systemd-nspawn container to maintain a static system and avoid the library issues that often plague matlab installs after significant updates to libraries in Arch. Refer to [[Systemd-nspawn]] for detailed information on setting up such containers.
 
The following instruction is to get a MATLAB R2021b installation running in a minimal Debian 11 environment. It assumes MATLAB is already installed as normal in "/usr/local/MATLAB/R2021b".


Use [[Xhost]] to allow the nspawn environment to use the existing X server instance, see also [[Systemd-nspawn#Use an X environment]].
Use [[Xhost]] to allow the nspawn environment to use the existing X server instance, see also [[Systemd-nspawn#Use an X environment]].


Create a minimal debian environment in a folder ("deb9" here) with:
Create a minimal Debian environment in a directory ("deb11" here) with:
 
$ debootstrap --include=systemd-container --components=main,contrib bullseye deb11
 
Set a password for the root user and create regular user:


  $ debootstrap --arch=amd64 stretch deb9
  $ systemd-nspawn -D deb11
passwd
useradd -m username
logout


Set a password for the root user and then boot the environment with:
and then boot the environment with:


  $ systemd-nspawn --bind-ro=/dev/dri --bind=/tmp/.X11-unix --bind=/usr/local/MATLAB/ -b -D deb9
  $ systemd-nspawn --bind-ro=/dev/dri --bind-ro=/tmp/.X11-unix --bind=/dev/shm --bind=/usr/local/MATLAB --setenv=DISPLAY=:0 --setenv=MESA_LOADER_DRIVER_OVERRIDE=i965 -b -D deb11


Install the following packages to have the requisite libraries in the nspawn environment for MATLAB. "mesa-utils" and "usbutils" can be installed to debug graphics acceleration and usb interfaces for I/O with MATLAB.
Install the following packages to have the required libraries in the nspawn environment for MATLAB: https://github.com/mathworks-ref-arch/container-images/blob/master/matlab-deps/r2021b/ubuntu20.04/Dockerfile


$ apt-get install xorg build-essential libgtk2.0-0 libnss3 libasound2
"mesa-utils" and dependencies needs to be installed to support graphics acceleration.
"usbutils" can be installed to support usb interfaces for I/O with MATLAB.


Install the MATLAB-support (from contrib source) package in the environment for some convenient integration.  
Install the matlab-support (from contrib source) package in the environment for some convenient integration.  


  $ apt-get install matlab-support
  $ apt-get install matlab-support


Set the $DISPLAY variable to use your existing X server instance.
MATLAB can be launched from within the environment normally by using the binary at {{ic|''matlab_root''/bin}}.


  $ export DISPLAY=:0
Another way is to add something like
  -u username -a /usr/local/MATLAB/R2021b/bin/matlab -nosoftwareopengl -useStartupFolderPref


MATLAB can be launched from within the environment normally by using the binary at $MATLABROOT/bin.
to the systemd-nspawn command above.

Latest revision as of 13:22, 31 March 2024

This article or section needs language, wiki syntax or style improvements. See Help:Style for reference.

Reason: unnecessarily verbose, sometimes written in in first person (Discuss in Talk:MATLAB)

From the official website:

MATLAB is a programming and numeric computing platform used by millions of engineers and scientists to analyze data, develop algorithms, and create models.

Overview

MATLAB is proprietary software produced by The MathWorks and requires a license to obtain, install, and activate. New versions of MATLAB are released twice a year, release names are composed of R, the year of the release and a or b. Arch Linux is not officially supported. [1]

Installation

A complete copy of the MATLAB software must be obtained before it can be installed. The MATLAB software is available to licenses holders on both a DVD and through the MathWorks website. In addition to the software a file installation key is required for installation. It is possible to install MATLAB either with the MATLAB Package Manager, matlabAUR, or from the MATLAB installation software directly. The recommended and most robust method is by using the MATLAB Package Manager, as it automates the installation of both MATLAB and toolboxes. Since the standard MATLAB installer does not support Wayland, the MPM is the only way to install MATLAB if running Wayland. Please note that MATLAB itself will require xwayland.

Installing with MATLAB Package Manager (MPM)

MATLAB Package Manager (MPM) offers a streamlined method to install MATLAB and accompanying MathWorks products on Linux systems, directly from the command line. This utility facilitates programmatic installation without necessitating user sign-in, a File Installation Key, or a pre-acquired license file, deferring activation and licensing to post-installation. MPM permits specification of MATLAB release version, additional toolboxes, and installation directory. Additionally, it serves well for constructing MATLAB Docker containers. As of 2023, the MATLAB installer does not support Wayland, and this is an easy way to install MATLAB via command-line.

Here's how to acquire MPM and set it up for execution (ensure wget is installed):

wget https://www.mathworks.com/mpm/glnxa64/mpm
chmod +x mpm

Installation of MATLAB and desired products is conducted with the following syntax:

./mpm install --release=<release> --destination=<destination> [--products] <product1> <product2> [...]

For instance, to install MATLAB R2021b along with select toolboxes to a specified directory, the command would be:

./mpm install --release=R2021b --destination=/home/username/matlab MATLAB Simulink Deep_Learning_Toolbox Parallel_Computing_Toolbox

The full list of correctly formatted product names can be found within the template input files.

Installing from the MATLAB installation software

The MATLAB installation software is self contained and does not require any additional packages to install in silent mode. To install with the GUI a working Xorg graphical display is necessary. Wayland is not officially supported yet, so it will run in a Xwayland session. The installation is handled by the install script. You can run the script as root to install MATLAB system-wide or your user to install it only for you.

During the installation, you are asked if you want symlinks to be created. If you did not choose to do so, you can now manually create a symlink in /usr/local/bin to make it easier to launch in terminal:

# ln -s /{MATLAB}/bin/matlab /usr/local/bin

Or you could add MATLAB install path to PATH environment variable.

Note: If the installation crashes with Failed to launch web window with error: Unable to launch the MATLABWindow application., see #Unable to launch the MATLABWindow application for a workaround.

Desktop entry

Optionally create a desktop entry. The MIME type of MATLAB files is text/x-matlab.

Start matlab with:

  • -desktop to run Matlab without a terminal.
  • -nosplash to prevent the splash screen from showing up.

In order for icons to appear correctly StartupWMClass needs to be set in the desktop entry. To find it out start MATLAB, run xprop | grep WM_CLASS and select the MATLAB window.

Example desktop entry:

/usr/share/applications/matlab.desktop
[Desktop Entry]
Type=Application
Terminal=false
MimeType=text/x-matlab
Exec=/usr/local/MATLAB/R20xyz/bin/matlab -desktop
Name=MATLAB
Icon=matlab
Categories=Development;Math;Science
Comment=Scientific computing environment
StartupNotify=true

If one need to set environment variable, one could prepend env in Exec, for example, to system's libfreetype:

Exec=env LD_PRELOAD=/usr/lib/libfreetype.so.6 matlab

One might want to use the system's libstdc++.

Installing from the AUR package

The matlabAUR package is designed to allow MATLAB to be integrated into and managed by Arch. The advantage of the matlabAUR package is that it manages dependencies and some of the nuances of the installation process. Note however, that the package does not contain the installation files, and you are expected to place them in the cloned package folder yourself. It can be problematic to build the package using AUR helpers, so you are expected to do so manually. You can obtain the actual MATLAB software using the installer from the MathWorks website.

Warning: The EULA for the proprietary MATLAB software is restrictive and it prohibits distribution and modification of the installation files. The installation method described in this section should only be performed on the system on which the software is going to be installed and the package should be deleted from the installation location and the pacman cache following installation. Redistributing the built package is a violation of the MATLAB EULA.
  • Clone the matlabAUR package and cd into it.
  • Download the zip file containing the MATLAB installer from MathWorks into the current directory. Extract the zip to the matlab subdirectory:
$ bsdtar xC matlab -f matlab_XXXXX_glnxa64.zip
  • Run the extracted installer with:
$ ./matlab/install
  • The installer gives you a choice of either installing the software now or only downloading selected modules. Choose the second option. This option may also be under the "Advanced Options" dropdown menu.
  • The installer will give you an option to change the download path. You might want to change it to something temporary (like /tmp if you have big enough ram disk) as you will soon move the contents to a different location.
  • Wait for the download to finish and close the installer. Merge the downloaded archives into the extracted matlab subdirectory:
$ rsync -a /selected/download/folder/YYYY_MM_DD_HH_MM_SS/ matlab
  • Then package the directory into a tarball:
$ tar -cvf matlab.tar matlab
  • Download your licence:Go to your MathWorks account and click on the licence number you want to use. Then, go to the Install and activate tab and select Activate to retrieve licence File. Follow the instructions and download the licence file needed for the installation. Name the file matlab.lic and place it in the AUR package directory. There will also be a File Installation Key (FIK) visible on the MathWorks website. Copy-paste it in a new file named matlab.fik and save it next to PKGBUILD just like you did with the matlab.lic.
  • Now, you will create a pacman package. You can customize the modules you want the package to contain by modifying the PKGBUILD or leave it at default:
PKGBUILD
...
# Limit products to lower size, set this to true to do a partial install
partialinstall=false
# Example list of products for a partial install; check README.md for details
products=(
  "MATLAB"
  #---MATLAB Product Family---#
  "Curve_Fitting_Toolbox"           # Math and Optimization
  "Database_Toolbox"              # Database Access and Reporting
  "Deep_Learning_HDL_Toolbox"
  "Deep_Learning_Toolbox"
  "DSP_System_Toolbox"
  "Global_Optimization_Toolbox"
  "GPU_Coder"
  "MATLAB_Coder"                # Code Generation
  "MATLAB_Compiler"               # Application Deployement
  "MATLAB_Compiler_SDK"
  "Optimization_Toolbox"
  "Parallel_Computing_Toolbox"        # Parallel computing
  "Partial_Differential_Equation_Toolbox"
  "Reinforcement_Learning_Toolbox"
  "Statistics_and_Machine_Learning_Toolbox"   # AI, Data Science, Statistics
  "Symbolic_Math_Toolbox"
  "Text_Analytics_Toolbox"
  #---Application Products---#
  "Audio_Toolbox"
  "Bioinformatics_Toolbox"          # Computational Biology
  "Computer_Vision_Toolbox"
  "Image_Processing_Toolbox"          # Image Processing and Computer Vision
  "Signal_Processing_Toolbox"         # Signal Processing
  "Wavelet_Toolbox"
)
...
  • Finally, use makepkg command to build and install the package:
$ makepkg -sri

Configuration

Java

The MATLAB software is bundled with a JVM and therefore it is not necessary to install Java. The JVM version supported by MATLAB is listed in System Requirements & Platform Availability or simply type version -java in MATLAB. One could set the MATLAB_JAVA environment variable to use custom JVM, for example, to specify the jre8-openjdk JRE, launch MATLAB with:

$ env MATLAB_JAVA=/usr/lib/jvm/java-8-openjdk/jre matlab

OpenGL acceleration

MATLAB can take advantage of hardware based 2D and 3D OpenGL acceleration. Support for hardware acceleration needs to be configured outside of MATLAB. Appropriate video drivers need to be installed along with the OpenGL utility library glu package. If X11 forwarding is being used, the video drivers need to be installed on both the client and server. To check if MATLAB is making use of hardware based OpenGL acceleration run:

$ matlab -nodesktop -nosplash -r "opengl info; exit" | grep Software

If "software rendering" is not "false", then there is a problem with your hardware acceleration. If this is the case make sure OpenGL is configured correctly on the system. This can be done with the glxinfo program from the mesa-utils package:

$ glxinfo | grep "direct rendering"

If "direct rendering" is not "yes", then there is likely a problem with your system configuration.

If glxinfo works but not matlab, you can try to run:

$ export LD_PRELOAD=/usr/lib/libstdc++.so; export LD_LIBRARY_PATH=/usr/lib/xorg/modules/dri/; matlab -nodesktop -nosplash -r "opengl info; exit" | grep Software

If it works, you can edit Matlab launcher script to add:

export LD_PRELOAD=/usr/lib/libstdc++.so
export LD_LIBRARY_PATH=/usr/lib/dri/

After these changes, you may see low-level graphics errors in the MATLAB console such as:

com.jogamp.opengl.GLException: X11GLXDrawableFactory - Could not initialize shared resources for X11GraphicsDevice[type .x11, connection :0, unitID 0, handle 0x0, owner false, ResourceToolkitLock[obj 0x76ddc7cd, isOwner false, <6876ff80, 5d5c50dc>[count 0, qsz 0, owner <NULL>]]]
    at jogamp.opengl.x11.glx.X11GLXDrawableFactory$SharedResourceImplementation.createSharedResource(X11GLXDrawableFactory.java:326)
    at jogamp.opengl.SharedResourceRunner.run(SharedResourceRunner.java:297)
    at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.NullPointerException
    at jogamp.opengl.GLContextImpl.makeCurrent(GLContextImpl.java:688)
    at jogamp.opengl.GLContextImpl.makeCurrent(GLContextImpl.java:580)
    at jogamp.opengl.x11.glx.X11GLXDrawableFactory$SharedResourceImplementation.createSharedResource(X11GLXDrawableFactory.java:297)
    ... 2 more

In that case, create a file with the name 'java.opts' in the directory where MATLAB is executed (for example /usr/local/MATLAB/R2020a/bin/glnxa64) with the following line:

java.opts
-Djogl.disable.openglarbcontext=1

Sound

To confirm that MATLAB is able to use the default soundcard to present sounds run:

$ matlab -nodesktop -nosplash -r "load handel; sound(y, Fs); pause(length(y)/Fs); exit" > /dev/null

This should play an except from Handel's "Hallelujah Chorus." If this fails make sure ALSA is properly configured. This can be done with the speaker-test program from the alsa-utils package:

$ speaker-test

If you do not hear anything, then there is likely a problem with your system configuration.

GPU computing

MATLAB can take advantage of CUDA enabled GPUs to speed up applications. In order to take advantage of a supported GPU install the nvidia, nvidia-utils, ocl-icd, opencl-nvidia, and cuda packages. To check if MATLAB is able to utilize the GPU run:

$ matlab -nodesktop -nosplash -r "x=rand(10, 'single'); g=gpuArray(x); Success=isequal(gather(g), x), exit"  | sed -ne '/Success =/,$p'

Install supported compilers

In order to access the full functionality of MATLAB (e.g., to use Simulink, Builder JA, and MEX-file compilation), supported versions of the gcc, g++, gfortran, and jdk compilers must be installed. Details about the supported compilers for the current release and previous releases are available online. Many of the supported gcc, g++, jdk compiler versions for past MATLAB releases are available from the AUR (e.g., gcc43AUR, gcc44AUR, gcc47AUR, gcc49AURand jdk7AUR), while past versions of the gfortran compilers are not packaged.

To use previous versions of the gcc, g++, and gfortran compilers with MEX files, edit ${MATLAB}/bin/mexopts.sh and replace all occurrences of CC='gcc' with CC='gcc-4.X', CXX='g++' with CXX='g++-4.X', and FC='gfortran' with FC='gfortran-4.X', where X is the compiler version appropriate for the particular MATLAB release.

Note:
  • Newer versions of Matlab (at least 2017a) does not seem to respect the ${MATLAB}/bin/mexopts.sh customization. Instead it uses ${MATLAB}/bin/glnxa64/mexopts/LANG_glnxa64.xml file.
  • Though, it is not officially supported, one could still use higher version of compiler, and ignore the warnings.

Help browser

The help browser uses valuable slots in the dynamic thread vector and causes competition with core functionality provided by libraries like the BLAS that also depend on the dynamic thread vector. The help browser can be configured to use fewer slots in the dynamic thread vector with

>> webutils.htmlrenderer('basic');

This is a persistent change and to reverse it use

>> webutils.htmlrenderer('default');

Serial port access

To successfully connect to any serial port, MATLAB expects to have write access directly to /var/lock which is not allowed on Arch Linux for security reasons. Instead of allowing this access just for MATLAB, you can work around this problem by redirecting device locking using lockdev-redirectAUR. All you have to do is executing MATLAB like this:

# lockdev-redirect /{MATLAB}/bin/matlab

If you have created a .desktop file as shortcut to MATLAB, then add "lockdev-redirect" as a prefix to your "Exec=" entry.

HiDPI and 4k

See HiDPI#MATLAB.

Troubleshooting

Warning: Initializing MATLAB Graphics failed

This error seems to happen on multi-monitor setups, see this forum post.

Blackscreen in help browser and livescripts

In order to use help browser and livescripts install libselinuxAUR.

Static TLS errors

MATLAB has a number of libraries that have been compiled with static thread local storage (TLS) including the help browser doc and the BLAS libraries. For example,

>> doc('help');
>> ones(10)*randn(10);
Error using  * 
BLAS loading error:
dlopen: cannot load any more object with static TLS

is related to the bugs:

A more general solution of recompiling glibc has also been suggested. [2]

Blank/grey UI when using WM (non-reparenting window manager)

See Java#Gray window, applications not resizing with WM, menus immediately closing.

Corrupted text and fonts in menus and fields

If you notice that the menus or the input fields are corrupted or not appearing correctly then you can try to activate the "Use antialiasing to smooth desktop fonts" option in Matlab preferences, it seems to solve the problem. Go to Preferences -> Matlab -> Fonts and activate it. You will need to restart Matlab in order to take affect.

Installation dependencies missing

Matlab might complain that it cannot find a package. Look at the package name and install it with Pacman, or in the case of x86_64 there are some libraries only in AUR. matlabAUR and matlab-dummyAUR[broken link: package not found] packages contain a list of up-to-date dependencies for the newest Matlab version.

See also #Unable to launch the MATLABWindow application.

Installation error: archive is not a ZIP archive

During the installation you can get:

The following error was detected while installing package_name: archive is not a ZIP archive 
Would you like to retry installing package_name? If you press No, the installer will exit without completing the installation. More information can be found at /tmp/mathworks_root.log

Matlab downloads all packages to /tmp/ directory which resides in RAM and is maximum size of half of available memory. In this case it is not enough for installation files and Matlab 2019a installer will warn you about this. If it did not, or if you ignored the warning, you will have got the above error.

You can either resize tmpfs (3,5 GB is not enough, 6 GB works), or remove packages from base install and add them later with built-in Matlab add-on installer.

Install-time library errors

  • Make sure that the symlink bin/glnx64/libstdc++.so.6 is pointing to the correct version of libstdc++.so.xx (which is also in the same directory and has numbers where 'xx' is). By default, it may be pointing to an older (and nonexistent) version (different value for 'xx').
  • Make sure the device you are installing from is not mounted as noexec
  • If you downloaded the files from Mathworks' website, make sure they are not on an NTFS or FAT partition, because that can mess up the symlinks. Ext4 or Ext3 should work.

Hangs on rendering or exiting with Intel graphics

Some users have reported issues with DRI3 enabled on Intel Graphics chips. A possible workaround is to disable DRI3 and run MATLAB with hardware rendering on DRI2; to do so, launch MATLAB with the environment variable LIBGL_DRI3_DISABLE set to 1:

LIBGL_DRI3_DISABLE=1 /{MATLAB}/bin/matlab

If the previous workaround does not work, the issue can be circumvented by selecting software rendering with the MATLAB command (beware, performance may be very poor when doing e.g. big or complex 3D plots):

opengl('save','software')

See [3] and [4] for more.

LiveScript errors

If you get the error when attempting to load or create a LiveScript:

 Viewing matlab live script files is not currently supported by this operating system configuration
  • It could be because of broken symlinks of libgcrypt and other dependencies, after system updates. On the first start of the Live Editor the components are extracted and these libary symlinks are created (if not existing).
A solution is to simply delete the whole folder containing the broken symlinks and the extracted components, which are in the installation directory:
matlab_root/sys/jxbrowser-chromium
Or, if the installation directory is not user writable, then in:
~/.matlab/R2017b/HtmlPanel
Matlab will then regenerate the contents on the next Live Editor start.
A better option is to replace libgcrypt symlink in this extraction directory with a less precise one. For example, after extraction, this link to /lib64/libgcrypt.so.20.2.4 is created. Replace it with e.g. /lib64/libgcrypt.so.20.
Matlab R2020 does not contain a chromium directory anymore. Relinking the library file libcrypto.so.1.1 with the system file can resolve the issue. It is located in:
matlab_root/bin/glnxa64
>> com.mathworks.mde.liveeditor.widget.rtc.CachedLightweightBrowserFactory.createLightweightBrowser()

to get a more detailed error message.

  • A debugging console can be opened with
>> com.mathworks.mde.webbrowser.HtmlPanelDebugConsole.invoke;

Using webcam/video device

Make sure the correct support package add-ons are installed (webcam or OS Generic Video Interface for example). If running matlab as a user, make sure your user has write permissions to wherever the support packages are being downloaded and installed.

Since MATLAB R2017a, Image Acqusition Toolbox is using GStreamer library version 1.0. It previously used version 0.10.

In general, USB Webcam Support Package does a better job working with UVC and built-in cameras than OS Generic Video Interface Support Package.

MATLAB hangs for several minutes when closing Help Browser

This article or section needs language, wiki syntax or style improvements. See Help:Style for reference.

Reason: Written in first person (Discuss in Talk:MATLAB)

Since upgrade of glibc from 2.24 to 2.25, MATLAB (at least R2017a) hangs when closing Help Browser. The issue is related to the particular version of jxbrowser-chromium shipped with MATLAB. This issue is still present with glibc 2.26 and MATLAB R2017b and R2018a.

To fix this issue, download the latest jxbrowser and replace the following jars from MATLAB:

matlab_root/java/jarext/jxbrowser-chromium/jxbrowser-chromium.jar
matlab_root/java/jarext/jxbrowser-chromium/jxbrowser-linux64.jar

MATLAB should automatically unpack those jars into matlab_root/sys/jxbrowser-chromium/glnxa64/chromium when first opening Help Browser. Remove matlab_root/sys/jxbrowser-chromium/glnxa64/chromium directory to make sure MATLAB uses the latest jxbrowser.

Unfortunately, this workaround does not work in R2017b anymore. Going deeper into investigation of this issue, it is related to a crash of one of jxbrowser-chromium processes. The parent process of jxbrowser-chromium then sits there and waits for response from a process that is already dead. This causes MATLAB main window to freeze. You can easily unfreeze MATLAB by manually killing all leftover jxbrowser-chromium processes.

I have come up with this simple script that uses inotify and waits for user to close Help browser in MATLAB. It triggers when user closes Help browser and sends kill signal to all leftover jxbrowser-chromium processes:

#!/bin/sh

if [ -z "$1" ]; then
	REL=R2017b
else
	REL=$1
fi

JXPATH="/path/to/MATLAB/$REL/sys/jxbrowser-chromium/glnxa64/chromium"
CMD="inotifywait -m -e CLOSE $JXPATH/resources.pak"

#Exit if the daemon is already active
if ! pgrep -f "$CMD" > /dev/null; then
	#Wait for user to close Help Browser, then killall leftover jxbrowser processes
	$CMD |
	while read line
	do
		killall "$JXPATH/jxbrowser-chromium"
	done
else
	exit
fi

I run this script as part of my MATLAB start script like that:

~/bin/unfreeze_matlab.sh R2017b &

To make sure that this background job is killed when I exit MATLAB, I use this in the beginning of MATLAB start script:

trap "trap - SIGTERM && kill -- -$$" SIGINT SIGTERM EXIT

Some dropdown menus cannot be selected

In some interfaces - such as Simulation Data Inspector or Simulink Test Manager - nothing happens when choosing an item in dropdown menu (for example, when trying to change a number of subplots in Simulation Data Inspector). To work around this issue, hold down the Shift key while clicking the item in dropdown menu.

Not starting - licensing error

In case MATLAB will not start from a desktop environment by the call of its desktop file one should see the output as you start it from the terminal.

For a Licensing error such as:

# matlab
MATLAB is selecting SOFTWARE OPENGL rendering.
License checkout failed.
License Manager Error -9
This error may occur when: 
-The hostid of this computer does not match the hostid in the license file. 
-A Designated Computer installation is in use by another user. 
If no other user is currently running MATLAB, you may need to activate.

Troubleshoot this issue by visiting: 
https://www.mathworks.com/support/lme/R2017a/9

Diagnostic Information:
Feature: MATLAB 
License path: /home/<USER>/.matlab/R2017a_licenses/license_<NUM>_R2017a.lic:/home/<USER>/.matlab/R2017a_licenses/lice
nse_Darkness_<NUM>_R2017a.lic:/opt/MATLAB/R2017a/licenses/license.dat:/opt/MATLAB/R2017a/licenses/*
.lic 
Licensing error: -9,57.

A re-activation might solve the problem.

/usr/local/MATLAB/R2017a/bin/activate_matlab.sh -javadir /usr/lib/jvm/java-8-openjdk/jre/

MATLAB crashes with "Failure loading desktop class" on startup

In case MATLAB will not start and starting it from command line gives you the following error:

$ matlab
Fatal Internal Error: Internal Error: Failure occurs during desktop startup. Details: Failure loading desktop class.

and you have the option -Dswing.defaultlaf=com.sun.java.swing.plaf.gtk.GTKLookAndFeel set in your _JAVA_OPTIONS environment variable, start MATLAB with

$ _JAVA_OPTIONS= matlab

If this works, add the line

export _JAVA_OPTIONS=

to your MATLAB launcher script. Optionally re-add other Java options.

Unable to type in text fields of interfaces based on MATLABWindow

This article or section needs language, wiki syntax or style improvements. See Help:Style for reference.

Reason: Written in first person (Discuss in Talk:MATLAB)

Since R2018a, it is not possible to type text in interfaces based on MATLABWindow - like Signal Editor, Add-Ons Explorer and others. MATLABWindow and MATLAB's webwindow infrastructure is based on Chromium Embedded Framework, and it looks like a known and long standing bug: https://bitbucket.org/chromiumembedded/cef/issues/2026/multiple-major-keyboard-focus-issues-on

One possible workaround is to switch focus from the MATLABWindow to another window and then switch back - so that you can type.

To elaborate more on this workaround (since the problem is still there in R2018b), here is what i did in my Openbox config (note that the A-Middle keybinding already exist in default config):

    <mousebind button="A-Middle" action="Press">
       <action name="Unfocus"/>
       <action name="Focus"/>
     </mousebind>

Now, whenever it is not possible to type in a text field, I press Alt+Mouse middle mouse and then I can type again.

This problem is critical during installation. After one clicks some elements in the installation window, he will not be able to type into any textbox anymore and switching between windows does not always work. To circumvent the issue, one shall only use key-press, instead of mouse click during installation. MATLAB installer has a poor support on Wayland, one may also consider using other WM instead during installation.

Unable to launch the MATLABWindow application

In MATLAB versions R2018b until R2022b, the installer crashes as follows:

 $ ./install 
terminate called after throwing an instance of 'std::runtime_error'
  what():  Failed to launch web window with error: Unable to launch the MATLABWindow application. The exit code was: 127
[1]    1409378 IOT instruction (core dumped)  ./install

To find out why MATLABWindow is crashing, run it manually to get detailed information.

 $ ./bin/glnxa64/MATLABWindow 
bin/glnxa64/MATLABWindow: symbol lookup error: /usr/lib/libcairo.so.2: undefined symbol: FT_Get_Color_Glyph_Layer

FT_Get_Color_Glyph_Layer is a symbol of freetype2, which indicates a library incompatibility between the MATLAB application and the Arch Linux packages. [5]

To fix this, put aside MATLAB's libfreetype.so*.

$ rm ./bin/glnxa64/libfreetype.so*

You can also use LD_PRELOAD environment variable to force MATLAB use Arch Linux's libfreetype without removing the lib file.

$ export LD_PRELOAD=/lib64/libfreetype.so
$ ./install

Similarly, if the error is caused by undefined symbol: g_log_structured..., put aside MATLAB's libglib-2.0.so*. If the error is caused by path to/libstdc++.so.6: version `CXXABI_1.3.9' not found (required by _somelibrary_), put aside MATLAB's libstdc++.so.6.

Cannot verify university login during installation

For total headcount license users, MATLAB will pop-up a window asking the user to login with their credentials in a web browser. However, if run with sudo, most browsers (especially chromium) will not run. To circumvent this problem, one shall 'active the computer' through MATLAB's website using a browser by a normal user. See this issue

Missing libcrypt.so.1

If you get this error when launching or installing MATLAB (R2020a and later), install libxcrypt-compat.

Running installer as root does not launch the GUI

If you run the installer as root and the GUI does not appear (but does appear without launching as root), try temporarily allowing the root user to access the X Server by running the following commands in order (where ./install is the command to run the installer as root):

$ xhost +SI:localuser:root
# ./install
$ xhost -SI:localuser:root

Note that the last command should be executed upon finishing the installation process, and localuser is a string literal. See this support answer, and xhost(1).

In addition, verify that the DISPLAY environment variable is set.

An alternative is to install MATLAB as a local user.

GUI installer is unable to create the target folder when installing as user

Make the folder manually (as root), and take ownership. The path is typically /usr/local/MATLAB

# mkdir -p /path/to/MATLAB/R20XXx
# chown -R $LOGNAME: /path/to/MATLAB/R20XXx

MATLAB crashes when opening Simulink

When running from terminal the error message is:

Inconsistency detected by ld.so: ../elf/dl-tls.c: 597: _dl_allocate_tls_init: Assertion `listp != NULL' failed!

See upstream bug report here: https://www.mathworks.com/support/bugreports/details/2632298

MATLAB cannot open or create script files

See #Unable to launch the MATLABWindow application.

Calls to mex fail

If calls from MATLAB or Simulink to mex (e.g. rapid accelerator) fail with the error *.mexa64 is not a MEX file, even though the resulting file is usable, it may help to edit in either matlab/bin/ or ~/.matlab7rc.sh by changing the LDPATH_PREFIX variable from its empty default: [6]

matlab/bin/.matlab7rc.sh (or ~/.matlab7rc.sh)
...
    case "$ARCH" in
	glnx*) #  Make sure you are modifying case glnx*
	    AUTOMOUNT_MAP=''
	    DISPLAY="$DISPLAY"
	    ARCH="$ARCH"
	    TOOLBOX="$TOOLBOX"
	    MATLABPATH="$MATLABPATH"
	    SHELL="$SHELL"
	    LDPATH_PREFIX='/usr/lib' 
...

Incompatibilities with some python libraries using MKL

Some python code running inside matlab may fail with an error mentioning Parameter * was incorrect on entry to . This can be avoided by calling

py.sys.setdlopenflags(int32(bitor(int64(py.os.RTLD_NOW), int64(py.os.RTLD_DEEPBIND))));

or

py.sys.setdlopenflags(int32(bitor(int64(py.os.RTLD_LAZY), int64(py.os.RTLD_DEEPBIND))));

directly before any calls to py and after calls to pyenv. See this support answer.

Settings not persisting between MATLAB restarts

In some cases on recent Arch systems matlab is unable to export .mlsettings files, preventing toolbox and some matlab settings from being saved to disk and persisted. These cases come from matlab trying to hard link new files from /tmp directly to the preferences directory (usually ~/.matlab/release where release is the matlab version, e.g. R2021b). As a workaround, run matlab with the $TMPDIR environment variable set to a folder on the same file system as the preferences directory. [7]

"Unable to open this file in the current system configuration"

The error can be fixed by setting aside the libfreetype.so.6 in matlab_root/bin/glnxa64/. You may run the following command:

cd matlab_root/bin/glnxa64/
mv libfreetype.so.6 libfreetype.so.6.old

Symbols in toolstrip menus are not diplayed properly

This article or section needs expansion.

Reason: Explain which symbols are needed, so that users can choose any font providing them. (Discuss in Talk:MATLAB)

This issue can be fixed by installing noto-fonts.

Blank screen on Xwayland

As suggested in Wayland#Java, this issue can be fixed by adding in the Matlab launcher script:

export _JAVA_AWT_WM_NONREPARENTING=1

Desktop Error with text not rendering

Launching MATLAB you get an error dialog with a message of "desktop error" and the text doesn't render. The error log looks like this

ERROR
Crash report:
Ajava.lang.ExceptionInInitializerError
at com.mathworks.mde.cmdwin.CmdWin.<init>(CmdWin.java:111)
at com.mathworks.mde.cmdwin.CmdWin.<clinit>(CmdWin.java:107)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:264)
at com.mathworks.jmi.ClassLoaderManager.loadClass(ClassLoaderManager.java:442)
at com.mathworks.jmi.ClassLoaderManager.findClass(ClassLoaderManager.java:422)
at com.mathworks.jmi.Matlab$2.findClass(Matlab.java:517)
at com.mathworks.util.ClassLoaderBridge.findClass(ClassLoaderBridge.java:23)
at com.mathworks.widgets.desk.DTClient.createComponent(DTClient.java:275)
at com.mathworks.widgets.desk.Desktop.createClientComponent(Desktop.java:6468)
at com.mathworks.mde.desk.MLDesktop.createClientComponent(MLDesktop.java:1040)
at com.mathworks.widgets.desk.Desktop.createClientComponentWrapper(Desktop.java:6482)
at com.mathworks.widgets.desk.Desktop.setClientShowing(Desktop.java:7181)
at com.mathworks.widgets.desk.Desktop.setClientShowing(Desktop.java:7168)
at com.mathworks.widgets.desk.DTNestingContainer$ViewState.restore(DTNestingContainer.java:2910)
at com.mathworks.widgets.desk.DTNestingContainer$SplitState.restore(DTNestingContainer.java:2536)
at com.mathworks.widgets.desk.DTNestingContainer$SplitState.restore(DTNestingContainer.java:2537)
at com.mathworks.widgets.desk.DTNestingContainer$RootState.restore(DTNestingContainer.java:2422)
at com.mathworks.widgets.desk.DTNestingContainer$RootState.restore(DTNestingContainer.java:2417)
at com.mathworks.widgets.desk.DTNestingContainer.restoreState(DTNestingContainer.java:2291)
at com.mathworks.widgets.desk.DTMultipleClientFrame.restoreState(DTMultipleClientFrame.java:2791)
at com.mathworks.widgets.desk.Desktop.restoreLayout(Desktop.java:5947)
at com.mathworks.mde.desk.MLDesktop.restoreLayout(MLDesktop.java:1652)
at com.mathworks.widgets.desk.Desktop.restoreLayout(Desktop.java:5706)
at com.mathworks.mde.desk.MLDesktop.setDefaultDesktop(MLDesktop.java:1539)
at com.mathworks.widgets.desk.Desktop.initMainFrame(Desktop.java:296)
at com.mathworks.mde.desk.MLDesktop.initMainFrameFromThread(MLDesktop.java:844)
at com.mathworks.mde.desk.MLDesktop.access$600(MLDesktop.java:224)
at com.mathworks.mde.desk.MLDesktop$Initializer.run(MLDesktop.java:1215)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:758)
at java.awt.EventQueue.access$500(EventQueue.java:97)
at java.awt.EventQueue$3.run(EventQueue.java:709)
at java.awt.EventQueue$3.run(EventQueue.java:703)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:74)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:728)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:205)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
Caused by: java.lang.ArithmeticException: / by zero
at com.mathworks.mde.cmdwin.XCmdWndView.getPotentialColumns(XCmdWndView.java:1072)
at com.mathworks.mde.cmdwin.XCmdWndView.setCWFont(XCmdWndView.java:1651)
at com.mathworks.mde.cmdwin.XCmdWndView.initPrefs(XCmdWndView.java:907)
at com.mathworks.mde.cmdwin.XCmdWndView.<init>(XCmdWndView.java:401)
at com.mathworks.mde.cmdwin.XCmdWndView.<clinit>(XCmdWndView.java:329)
... 43 more

The error is related to missing fonts and can be fixed installing from the AUR the package ttf-ms-fonts

MATLAB in a systemd-nspawn

MATLAB can be run within a systemd-nspawn container to maintain a static system and avoid the library issues that often plague matlab installs after significant updates to libraries in Arch. Refer to Systemd-nspawn for detailed information on setting up such containers.

The following instruction is to get a MATLAB R2021b installation running in a minimal Debian 11 environment. It assumes MATLAB is already installed as normal in "/usr/local/MATLAB/R2021b".

Use Xhost to allow the nspawn environment to use the existing X server instance, see also Systemd-nspawn#Use an X environment.

Create a minimal Debian environment in a directory ("deb11" here) with:

$ debootstrap --include=systemd-container --components=main,contrib bullseye deb11

Set a password for the root user and create regular user:

$ systemd-nspawn -D deb11
passwd
useradd -m username
logout

and then boot the environment with:

$ systemd-nspawn --bind-ro=/dev/dri --bind-ro=/tmp/.X11-unix --bind=/dev/shm --bind=/usr/local/MATLAB --setenv=DISPLAY=:0 --setenv=MESA_LOADER_DRIVER_OVERRIDE=i965 -b -D deb11

Install the following packages to have the required libraries in the nspawn environment for MATLAB: https://github.com/mathworks-ref-arch/container-images/blob/master/matlab-deps/r2021b/ubuntu20.04/Dockerfile

"mesa-utils" and dependencies needs to be installed to support graphics acceleration. "usbutils" can be installed to support usb interfaces for I/O with MATLAB.

Install the matlab-support (from contrib source) package in the environment for some convenient integration.

$ apt-get install matlab-support

MATLAB can be launched from within the environment normally by using the binary at matlab_root/bin.

Another way is to add something like

-u username -a /usr/local/MATLAB/R2021b/bin/matlab -nosoftwareopengl -useStartupFolderPref

to the systemd-nspawn command above.