Borrar filtros
Borrar filtros

How to run the 'matlab -batch ...' with a different Matlab version

33 visualizaciones (últimos 30 días)
tom
tom el 28 de Feb. de 2023
Comentada: tom el 28 de Feb. de 2023
Hello,
on Windows, if I run 'matlab -batch myscript' from any shell, I can run Matlab in true batch mode. I also get the output redirect. Everything works fine!
However, I want to make sure to run Matlab R2021b, not a potential newer version. So instead of using the 'matlab' command, I either want to use the absolute path to the Matlab.exe of the given version, or I want to change what the matlab command is refereing to. The problem. The Matlab.exe does behave differently if I call it directly.
e.g. from powershell this works:
& matlab -batch "disp('hello')"
this does not work (at least it does not output) :
& "D:\Matlab\R2021b\bin\win64\Matlab.exe" -batch "disp('hello')"
(Both use the same Matlab version beneath)
How can make sure to always run a batch script for a given Matlab version and get the correct output redirected?

Respuesta aceptada

Steven Lord
Steven Lord el 28 de Feb. de 2023
Try launching the MATLAB executable directly in bin rather than the one in the $ARCH subdirectory under bin.
"D:\Matlab\R2021b\bin\matlab.exe" -batch "disp('hello')"

Más respuestas (0)

Categorías

Más información sobre Introduction to Installation and Licensing en Help Center y File Exchange.

Productos


Versión

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by