Run Matlab in Linux without graphical environment?

I am going to run a Matlab program in a remote Linux server using SSH. I was wondering how to run Matlab in Linux with only command line, which means there is no graphical environment?

Thanks.

Answers


Start MatLab with the the following flags

matlab -nodesktop -nojvm -nosplash
  • -nodesktop prevents the desktop

  • -nojvm prevents starting of the java virtual machine

  • -nosplash prevents the start-up splash screen.

Note, that, as Li-aung Yip noted in the comments, Mathworks does not recommend to use the -nojvm flag.


The command is matlab -nodesktop.

http://www.mathworks.de/help/techdoc/ref/matlabunix.html


matlab -nodisplay

See here about -nodisplay.

Then -nodesktop and -nosplash are unnecessary. They don't make sense in text mode.

It's probably not a good idea to add -nojvm unless you have a separate good reason to do so. Without the JVM, you lose some functionality whose absence might lead to confusion later on. Source: same link as above. On top of -nodisplay, it doesn't make your non-graphical Matlab session any less graphical.


Here are a couple of ways to run commands non-interactively.

Way 1:

matlab -nodisplay < myScript.m

Put exit as e.g. the last command in myScript.m.

Way 2:

matlab -nodisplay -r "try, myFunction(); catch e, disp(getReport(e)), exit(7), end, exit()" 

The second way is preferable, because e.g. if there is an error in the middle of the code, then the second way will print an error message and exit with a non-zero code. Whereas the first way is equivalent to typing the commands in directly, regardless of what Matlab says (which might be error messages).

In case the next question is "how to suppress the welcome message in text-mode Matlab?", it seems there is NO good way to get rid of it.


Need Your Help

Recusive association with FactoryGirl

ruby-on-rails ruby-on-rails-3 activerecord factory-bot

I have a category model. I am using ancestry gem to make it like a tree structure so that we can have sub categories. I have a simple factory for category that looks like this

Scala: F-Bounded Polymorphism Woes

scala generics types compilation structural-typing

Assume the existence of the following types and method: