In order to run a script you can open Matlab (you can prevent run it without the GUI using -nodisplay
and -nodesktop
flags), then run the script using the run
command, and finally close matlab using exit
.
You can do all this from a terminal with a single instruction:
matlab -nodisplay -nosplash -nodesktop -r "run('path/to/your/script.m');exit;"
However Matlab outputs the welcome message to the console before running your script. To get rid of the welcome message just skip the first 11 lines (10 depending on your Matlab version) using tail -n +11
So your final instruction will be:
matlab -nodisplay -nosplash -nodesktop -r "run('path/to/your/script.m');exit;" | tail -n +11