LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   (Something like...) passing an argument to a MATLAB script (https://www.linuxquestions.org/questions/programming-9/something-like-passing-an-argument-to-a-matlab-script-777303/)

Mike_V 12-21-2009 04:38 PM

(Something like...) passing an argument to a MATLAB script
 
Hi there, I have a MATLAB-LINUX question.

I have a MATLAB script (script.m) that looks something like this:

Code:

subject = '1234';

(then I do all sorts of things like
read a text file with "1234" in it,
etc and write out new text file with
1234 in the file name)

For the next subject I'm currently going into the script to replace '1234' with the number of the next subject. I know I could make the subject numbers into an array within MATLAB but that's not what I want.

What I would like to have is a one line command that passes the subject number '1234' to the script and runs the MATLAB script.

I've read another posting http://www.linuxquestions.org/questi...d.php?t=728099 that seems something like what I'm looking for but it's actually too complex for my purpose (and understanding).

I'm looking for something like this:

script.m will have the following first line:

Code:

subject = '$1';
And then I would like to type something like this in the linux terminal:

Code:

matlab -nodisplay "1234"='$1' script.m
so that it will run script.m for subject 1234

Thanks for any suggestions,

Mike_V 12-21-2009 05:04 PM

my own solution
 
my solution:

matlab -nodisplay /r "x=1234;script.m"

When script.m would start with

Code:

subject = 'x';

I found it here after I posted the message:
http://www.mathworks.com/support/sol...lution=1-1BS5S

I hope it is of use for others...


All times are GMT -5. The time now is 12:17 AM.