Effacer les filtres
Effacer les filtres

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

33 vues (au cours des 30 derniers jours)
tom
tom le 28 Fév 2023
Commenté : tom le 28 Fév 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?

Réponse acceptée

Steven Lord
Steven Lord le 28 Fév 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')"

Plus de réponses (0)

Catégories

En savoir plus sur Introduction to Installation and Licensing dans Help Center et File Exchange

Produits


Version

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by