フィルターのクリア

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

33 ビュー (過去 30 日間)
tom
tom 2023 年 2 月 28 日
コメント済み: tom 2023 年 2 月 28 日
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?

採用された回答

Steven Lord
Steven Lord 2023 年 2 月 28 日
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')"
  1 件のコメント
tom
tom 2023 年 2 月 28 日
Great. Thanks. This works!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeIntroduction to Installation and Licensing についてさらに検索

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by