0

Currently I call can only functions with string or integer arguments using this script

#!/bin/sh

matlab_exec=matlab
X="${1}(${2})"
echo ${X} > matlab_command_${2}.m
cat matlab_command_${2}.m
${matlab_exec} -nojvm -nodisplay -nosplash < matlab_command_${2}.m
rm matlab_command_${2}.m

However it only accepts strings or integers. To call it I would run this command

./run funtions arg1,arg2

How could I make it so it would take a matrix but through the command line

i.e matrix [1 2 3; 4 5 6; 7 8 9]

The Enigma
  • 137
  • 2
  • 6
  • [This link](http://www.mathworks.com/matlabcentral/answers/97204-how-can-i-pass-input-parameters-when-running-matlab-in-batch-mode-in-windows) seems to have some ideas. – Matthew Gunn Dec 01 '15 at 06:21
  • @MatthewGunn That link is Windows only. – rayryeng Dec 01 '15 at 06:34
  • @rayryeng I hope people can replace /r with -r when in a unix environment. – Matthew Gunn Dec 01 '15 at 06:39
  • 3
    @MatthewGunn you're expecting too much! :) – rayryeng Dec 01 '15 at 06:40
  • @rayryeng lol, and unfortunately, you're probably right ! – Matthew Gunn Dec 01 '15 at 06:41
  • @MatthewGunn :D. BTW, I'm not sure if you're up for it, but we've had a MATLAB chat room going for a while: chat.stackoverflow.com/rooms/81987/matlab-and-octave - whenever you like, drop by and say hello. It's nice to see a new active MATLAB user around. They're few and far in between! – rayryeng Dec 01 '15 at 06:42
  • @rayryeng Hey, I noticed you marked this question as a duplicate but the one that you linked doesn't explain how to used matrices as arguments. Would you know how to do that in matlab or where it was answered? – The Enigma Dec 01 '15 at 07:40
  • @TheEnigma I thought it did. In that case, follow Matthew Gunn's advice: http://www.mathworks.com/matlabcentral/answers/97204-how-can-i-pass-input-parameters-when-running-matlab-in-batch-mode-in-windows - Replace `/r` with `-r` as you're using Linux. – rayryeng Dec 01 '15 at 07:55
  • @TheEnigma This post also will help: http://stackoverflow.com/questions/2001183/how-to-call-matlab-functions-from-the-linux-command-line – rayryeng Dec 01 '15 at 08:48
  • @rayryeng used the same script to call matlab scripts but they don't accept matrices – The Enigma Dec 01 '15 at 22:54

0 Answers0