Matlab from the Ubuntu Menu

Getting stuff to work from the Ubuntu Menu is pretty straightforward, but I ran into some little problems that confused me with Matlab. This post goes through the steps and difficulties I had, which might be useful in general, not just in relation to Matlab.

First up, I installed the Student Edition of Matlab (currently R2009a and a steal at the student price), taking into account the fact that I’m running a 64-bit OS and the student edition doesn’t come with the 64-bit architecture libraries. Pretty confusing on first install as the installer detects the architecture but then can’t find the libs, but corrected using this guidance on the Mathworks website.

Once you’ve done that, you need to pass the argument ‘-glnx86′ to Matlab every time you start it up.

That’s a pain, plus the other boilerplate to run it in the background – so I tried to set up a menu option using ‘Main Menu’, which is the relevant administrative tool that comes with Ubuntu. It’s in System – Preferences – Main Menu if you’ve not used it before. Here’s a screenshot of it, set up with a Matlab launcher.


Main Menu with Matlab

The obvious thing is to give Main Menu the command that works from the command prompt, but no. Doing this results is strange behaviour where the splash screen fires up, disappears, and nothing. Checking the .xsession-errors log file in my home directory shows what’s happening. The application is launching in command line mode, writing its prompt to stdout, and then being shut down.

Kinda weird, maybe, as launching the app from the command line launches the Matlab GUI. Anyway, you also need to also add a ‘-desktop’ argument to the launcher command. My Matlab is installed in /opt/matlab, remember to change the path as appropriate for you.


The Matlab Launcher

You can also add the icon if you want by clicking where the Matlab icon is shown above, browsing to wherever you installed Matlab then into the ‘X11/icons’ directory, where you’ll find a number of icons.

Now you can launch the program from Main Menu, or drag-dropping it onto a panel, onto your desktop – wherever you like.