running matlab using command line

I am running matlab using Command line and using the following command to run the matlab.
"C:\Program Files\MATLAB\R2017b\bin\matlab.exe" -nodisplay -nosplash - nodesktop -r "run('Main.m');"
What should I add to this command to make sure Matlab doesn't get open and it just runs behind the scene and close automatically?

3 comentarios

Jan
Jan el 10 de Jul. de 2018
By the way, why not -r "Main;" instead of -r "run('Main.m');"?
dpb
dpb el 10 de Jul. de 2018
And for belt and suspenders, make sure Main.m ends with "exit"
Jan
Jan el 10 de Jul. de 2018
"C:\Program Files\MATLAB\R2017b\bin\matlab.exe" -nodisplay -nosplash - nodesktop -r "Main; exit"

Iniciar sesión para comentar.

Respuestas (3)

Jan Siegmund
Jan Siegmund el 26 de Mzo. de 2020
For R2019 users: -nodisplay & -nodesktop do not exist. Use:
matlab -batch "Main; exit"

2 comentarios

Matthias
Matthias el 5 de Ag. de 2020
Hi Jan, do you know how to prevent Matlab from opening that separtate Command Prompt window when launching it from the command line from R2019 and upwards?
Thanks!
Jan Siegmund
Jan Siegmund el 5 de Ag. de 2020
I'm not exactly sure what you mean. For me, this does not open a separate command prompt. The command starts the Matlab prompt, executes main, executes exit and returns to the system shell. Do you want to omit the Matlab command prompt?

Iniciar sesión para comentar.

dpb
dpb el 9 de Jul. de 2018

0 votos

Append an ampersand (&) to the command string
Lorenzo Luini
Lorenzo Luini el 1 de Abr. de 2024

0 votos

I am running a Matlab script at startup using the command as follows:
matlab.exe -r "run('C:\Users\User\Desktop\Realtimevis\RealtimeMeteoVisualization.m');"
The script opens up a figure to display some measurements in real time. How can I hide the Matlab command window while allowing the script to show the figure?
Thank you!
Best regards,
Lorenzo

Categorías

Más información sobre Startup and Shutdown en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 9 de Jul. de 2018

Respondida:

el 1 de Abr. de 2024

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by