Filter löschen
Filter löschen

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

26 Ansichten (letzte 30 Tage)
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.

Antworten (1)

Walter Roberson
Walter Roberson am 27 Jan. 2016
matlab -r -nojvm -nodisplay -nodesktop -nosplash "try; mat_script; catch; end; quit;"
  2 Kommentare
Brando Miranda
Brando Miranda am 27 Jan. 2016
thats not fully in the format that I requested because its unclear how to pass command line arguments.
Walter Roberson
Walter Roberson am 28 Jan. 2016
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.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Startup and Shutdown finden Sie in Help Center und File Exchange

Tags

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by