How can I pass input parameters to a MATLAB script from a Bash shell in Unix with arguments without opening MATLAB shell?
조회 수: 17 (최근 30일)
이전 댓글 표시
I wanted to run something like:
matlab -no_gui -no_matlab_shell my_matlab_script.m param1 param2 param3 ...
the idea was that I wanted MATLAB to print to STDOUT or somewhere the outputs of my program without opening the user interfaces. However, I had not have luck.
What I did was to get a similar behaviour was:
-bash-4.1$ matlab -r -nojvm -nodisplay -nosplash "run mat_script.m"
and I got out:
< M A T L A B (R) >
Copyright 1984-2015 The MathWorks, Inc.
R2015a (8.5.0.197613) 64-bit (glnxa64)
February 12, 2015
For online documentation, see http://www.mathworks.com/support
For product information, visit www.mathworks.com.
Academic License
Error using run (line 28)
Not enough input arguments.
which is obviously not what I wanted because
- It didn't run my script.
- It opened matlab shell.
So I wasn't sure why that happened. I read the docs and it says -r runs the command given to MATLAB so I a not sure why it didn't run it. However, once in the session it did obey me once I wrote:
run mat_script.m
so I am not sure whats going on.
댓글 수: 0
답변 (1개)
Walter Roberson
2016년 1월 27일
matlab -r -nojvm -nodisplay -nodesktop -nosplash "try; mat_script; catch; end; quit;"
댓글 수: 2
Walter Roberson
2016년 1월 28일
matlab -r -nojvm -nodisplay -nodesktop -nosplash "try; my_matlab_script param1 param2 param3 ...; catch; end; quit;"
Caution: you cannot pass parameters to a script, only to a function.
참고 항목
카테고리
Help Center 및 File Exchange에서 Startup and Shutdown에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!