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

39 Ansichten (letzte 30 Tage)
tom
tom am 28 Feb. 2023
Kommentiert: tom am 28 Feb. 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?

Akzeptierte Antwort

Steven Lord
Steven Lord am 28 Feb. 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')"

Weitere Antworten (0)

Kategorien

Mehr zu Programming finden Sie in Help Center und File Exchange

Produkte


Version

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by