필터 지우기
필터 지우기

How can I pass input parameters to a MATLAB script from a Bash shell in Unix with arguments without opening MATLAB shell?

조회 수: 26 (최근 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
  1. It didn't run my script.
  2. 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.

답변 (1개)

Walter Roberson
Walter Roberson 2016년 1월 27일
matlab -r -nojvm -nodisplay -nodesktop -nosplash "try; mat_script; catch; end; quit;"
  댓글 수: 2
Brando Miranda
Brando Miranda 2016년 1월 27일
thats not fully in the format that I requested because its unclear how to pass command line arguments.
Walter Roberson
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 CenterFile Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by