In a file S.m I store:
function s = S(a, b)
s = a + b;
I try to call the function from ssh shell like this:
matlab -r -nodisplay "S 3 5" > sum.txt
and I get a "not enough arguments in input" error. Can anyone see the reason for that?
In a file S.m I store:
function s = S(a, b)
s = a + b;
I try to call the function from ssh shell like this:
matlab -r -nodisplay "S 3 5" > sum.txt
and I get a "not enough arguments in input" error. Can anyone see the reason for that?
The -r
argument introduces the command to execute. The two cannot be separated by other arguments. That is, you can write
matlab -nodisplay -r "S 3 5" > sum.txt
or
matlab -r "S 3 5" -nodisplay > sum.txt
to get MATLAB to run the function S
with input arguments '3' and '5'. See the official documentation of the UNIX command matlab
for more information. There is a separate documentation page for Windows, where different options are allowed, but the -r
switch should still work.
Do note that the MATLAB statement
S 3 5
is equivalent to
S('3','5')
That is, the arguments are seen as strings. Convert them to numbers using the str2double
function.