elaRosca
elaRosca

Reputation: 3153

Passing a string to matlab from command line Linux

I want to be able to pass in to a matlab script (or function) an argument which is a string. It works fine with integers but I cannot do it with Strings. Example: /usr/bin/matlab -nodisplay -r 'main('ana')'

I get: Undefined function or variable 'ana'.

I tried " as well and I get an error.

I have the same issue when main is a script and I write something like:

/usr/bin/matlab -nodisplay -r 'a='ana';main'.

Can you please tell me how to do this?

Thanks.

Upvotes: 1

Views: 1802

Answers (2)

Thilo
Thilo

Reputation: 9157

Try using " as delimiter for the command string:

/usr/bin/matlab -nodisplay -r "a='ana';main"

Upvotes: 4

Maroun
Maroun

Reputation: 95948

Try to run: /usr/bin/matlab -r "main('blabla')"

Upvotes: 1

Related Questions