I was trying to add the installed matlab to the menu of Applications under Ubuntu 10.10.

I clicked Gnome-Menu -> Preference -> Main Menu -> Programming -> New Item, where I input the Matlab file .../MatlabR2010b/bin/matlab as the command, and selected the type to be "Application". Then I finished.

But when I click the item in the menu of Applications, the Matlab icon shows up for a few seconds and then nothing else happens.

If I select the type to be "Application in Terminal", then in the last step of adding Matlab to the Applications Menu, after I click the item in the menu of Applications, there will be firstly a terminal window and then the Matlab command window.

So I was wondering how to solve the problem of Matlab not starting when the type has been selected to be "Application"? Also is there a way to eliminate the terminal appearing when the type has been selected to be "Application in Terminal"?

The terminal will be visible, since it has launched as an application from terminal. If there is no terminal, its as good as launching as an application. What is the output of ls -l ../MatlabR2010b/bin/ I am guessing the matlab command is actually a script and not an executable.
–
theTuxRacerFeb 17 '11 at 6:02

@Kautubh: Thanks! The first line is #!/bin/sh.
–
TimFeb 17 '11 at 14:40

Although I'm using a more recent version of Ubuntu (and Matlab), this worked great for me:
I just installed Matlab 2012b on Ubuntu 12.10 and followed up by installing the matlab-support package in the Ubuntu Software Centre:

Its also nice to not have two icons in the launcher while MATLAB is running. To accomplish this, edit the *.desktop file containing the launcher for MATLAB (grep for matlab in ~/.local/share/applications) add add the following line to the bottom

Thanks! What does -c in /bin/sh -c mean? is /bin/sh same as bash?
–
TimFeb 17 '11 at 14:36

The first line of the file is #!/bin/sh. I tried "Application" with command "/bin/sh -c .../MatlabR2010b/bin/matlab ", but the problem remains i.e. just the Matlab icon flashes without actually Matlab starting.
–
TimFeb 17 '11 at 14:41

@Tim The -c tells the shell to perform the commands in the following command string. On Ubuntu /bin/sh launches the dash shell, which is a POSIX-compliant shell, but has a more minimal feature set than bash. However, I am not sure why this still isn't working for you.
–
Jon BrettFeb 18 '11 at 8:20