1
votes

I have a Matlab .m file that takes three input arguments:

calculate('input.txt','Alex','output.txt')

I would like to run this .m file in a shell script as follows:

matlab -nodisplay -nodesktop -r "run calculate('input.txt','Alex','output.txt)"

Unfortunately, this did not work. I get the following error:

Error using run (line 70)

calculate('input.txt','Alex','output.txt') not found.

Any pointer as to how I can give the input arguments/variables?

Thanks.

Note: The following did not work either - complaining too many arguments.

matlab -nodisplay -nodesktop -r "run calculate input.txt Alex output.txt"

1

1 Answers

3
votes

I think you just need to remove run. run is for scripts, not for functions (and anyway it's not necessary unless you need to specify the script's path). So, try

matlab -nodisplay -nodesktop -r "calculate('input.txt','Alex','output.txt')"

If your function calculate is not in Matlab's path, change to its folder first. For example

matlab -nodisplay -nodesktop -r "cd 'c:\users\Alex\SomeFolder'; calculate('input.txt','Alex','output.txt')"