Up to date hardware recommendations

Ian’s solution is the right one, with the tweak that after a Matlab update, you could do:

sudo dpkg-reconfigure matlab-support

to only type one command instead of two to reconfigure, but both methods will work.

The problem here is a Mathworks/Matlab induced one, and unfortunately Mathworks does a very poor job at this. Matlab ships its own outdated libraries that override the proper modern libraries shipping with Ubuntu. Depending on what Matlab version you install on which Linux distro version, Matlab’s libs will either be recent enough and work, or not – but more often not. Same problem happens on other operating systems, but the symptoms differ by OS. On Linux this is the typical symptom: Failure of OpenGL hw graphics to work by default.

A good thing to check is always if it works with Octave as a well integrated solution which many times fully fulfills the needs as well as Matlab.