Upgrading from ubuntu 16 to ubuntu 18

Solution 1:

Even latest MATLAB does not come in deb-packages.
It is usually installed to /opt or /usr/local or into your home folder.

So it will not be removed by upgrade in any way.