-   Programming (
-   -   (Something like...) passing an argument to a MATLAB script (

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:


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 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:


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


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


subject = 'x';

I found it here after I posted the message:

I hope it is of use for others...

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