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 envir
Putting the other answers together plus some more error handling, save the following as an executable file matlab-headless
:
#/usr/bin/env bash
# restore the "sane" state of the terminal at the end
# otherwise interrupting the process may leave the terminal messed up
trap 'stty sane' EXIT
command="try, $1;, catch e, stack=getReport(e); fprintf(1, '%s\n', stack);, end, exit;"
# tail gets rid of the welcome message banner
matlab -nodisplay -nodesktop -nosplash -r "$command" | tail -n +11
Now you can run a Matlab command as:
matlab-headless "somecommand('bla', 42)"