I found a similar question here that doesn't help me so I'm asking my own.
I have a matlab script that perfectly works under linux with nohup command.
Unfortunately, I need to run that on windows also. But I can't understand why my command still doesn't work.
My script does a certain loop but after the first it stops giving me an error about the java or something. I must tell you that the same problem occur under linux if I don't put the -nodisplay
command.
My batch line is the following
matlab -nodisplay -automation -r "run('myfile.m')" -logfile output.txt -minimize
Please help me.
edit:
I think I found my issue the problem is when I use -nodisplay
under linux the command usejava('awt')
works because my java environment is disabled, however this does not happen under windows! Why?
second edit: I think I found something that is quite similar to what I needed.
matlab -noawt -noFigureWindows -r "run('myfile.m')" -logfile output.txt -minimize
The analysis runs, without saying nothing, but the MATLAB command window still opens minimized..uhm I'd rather having anything to open up!
I must add another thing..nohup
never waits and go forward until it reaches the end of the script, nevertheless using any other batch command such as start
if there is any input request or "wait" it stops until someone gives an input!
The undocumented
-noawt
option will prevent the GUI functionality, but let Java run. Combine that with-noFigureWindows
, as you discovered, and you should have what you need. Alternatively, you can turn off figure display via your M file withset(0,'DefaultFigureVisible','off')
.To see if Java actually loaded, run
ver
orversion -java
. Here's what I see with-nojvm
.Then, using Windows'
start /b /min MATLAB.exe ...
should launch it minimized and without holding a command window opened.To make MATLAB invisible try using the tiny NirCmd command line tool as follows,
I think that should do it, but make sure you start the actual
MATLAB.exe
in thebin\<architecture>
folder, not justbin\matlab.exe
because when it launches the actual MATLAB.exe, it will not be hidden.