Run Matlab in Linux without graphical environment?
Start MatLab with 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.
matlab execute script from linux command line
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
How to launch MATLAB without a desktop in Windows
The -nodesktop
option was introduced when MATLAB got its Java UI. The option starts MATLAB with the previous interface. I guess they have stopped officially supporting it, but they never removed the option.
MATLAB on Windows has never been quite as comfortable running in a terminal as the Linux and macOS versions—on those OSes, MATLAB does run in the terminal with the -nodesktop
option, as they did before the Java UI was introduced.
If you want to run MATLAB non-interactively, use the -batch
option. The -r
is intended for interactive use, and therefore launches the desktop. The -batch
option:
- Starts without the desktop
- Does not display the splash screen
- Executes statement
- Disables changes to preferences
- Disables toolbox caching
- Logs text to stdout and stderr
- Does not display modal dialog boxes
- Exits automatically with exit code 0 if statement executes successfully. Otherwise, MATLAB terminates with a non-zero exit code.
(from the docs).
In your case, instead of
matlab -wait -nodesktop -nosplash -r "pause(10); quit"
you should do
matlab -batch "pause(10)"
(I don't know if -wait
is still needed on Windows, this is not clear in the documentation, and I don't have Windows to test this.)
Run MATLAB in command line allowing display of plots
Under Linux, to run MATLAB in a terminal window use the -nodesktop
option. It causes MATLAB to start without the GUI, with all text input and output to happen through the terminal window. But it does not disable the JVM software altogether and so allows interactive figure windows to be displayed.
The -nojvm
option disables the JVM software, disallowing all Java-based components of MATLAB, including figure windows. The -nodisplay
option disables al graphical display output, but doesn't disable the JVM.
For more details, see the documentation.
MATLAB without display on a Linux server
My understanding of the message is that Matlab tries to start the Desktop, which is written in Java and uses Swing components, but this fails. I don't know though why it would try to start the Desktop since you've given the -nodisplay
option.
Try to use the -nodesktop
option additionally.
Run Selection in MATLAB from Linux Command Line
AFAIK there is a no-desktop mode in MATLAB, which you can access by running it with -nodesktop parameter, this should provide you with what you need. You can find more info on official MATLAB pages
run matlab script from command line or shell
Yes, you can call matlab from command prompt. In a windows machine it will look like this depending on your matlab installation path:
"C:\Path\to\matlab\matlab.exe" -r matfile.m
But it does open up Matlab gui. I do not know how to run it silently, but including
exit
at the end of your routine will close it automatically.
Open a MATLAB GUI from terminal
If you don't have the MATLAB Compiler you cannot run your GUI without also running the MATLAB process. However, you can run your GUI without the MATLAB desktop showing, which I think is what you want. If your GUI main function is called myGUI
you could run this command from a linux terminal:
matlab -nodesktop -r "myGUI"
MATLAB will still run in your terminal, so you might want to add a CloseRequestFcn that exits MATLAB. See http://www.mathworks.com/help/matlab/ref/figure-properties.html#prop_CloseRequestFcn.
Related Topics
Rsync How to Include Directories But Not Files
Bluez: Advertise Service/Gatt Server Example
How to Copy Multiple Files from a Different Directory Using Cp
Svn Error: Can't Convert String from Native Encoding to 'Utf-8'
Examining C/C++ Heap Memory Statistics in Gdb
Why Do I Have to Use Bash -L -C Inside My Container
Linux-Based Firmware, How to Implement a Good Way to Update
How to Remove the Win10's Path from Wsl
How to Change All Occurrences of a Word in All Files in a Directory
Delete All System V Shared Memory and Semaphores on Unix-Like Systems
Hard Time in Understanding Module_Device_Table(Usb, Id_Table) Usage
How to Install Maven on Redhat Linux
How to Remove Duplicate Words from a Plain Text File Using Linux Command
How to Find the Tomcat 7 Installation Folder on Linux Ami in Elastic Beanstalk
Find and Basename Not Playing Nicely