필터 지우기
필터 지우기

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')"

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Introduction 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