Latest LQ Deal: Latest LQ Deals
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 12-21-2009, 04:38 PM   #1
Registered: Apr 2009
Location: Boston MA
Distribution: CentOS 6.2 x86_64 GNU/Linux
Posts: 59

Rep: Reputation: 19
(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,
Old 12-21-2009, 05:04 PM   #2
Registered: Apr 2009
Location: Boston MA
Distribution: CentOS 6.2 x86_64 GNU/Linux
Posts: 59

Original Poster
Rep: Reputation: 19
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...

Last edited by Mike_V; 12-21-2009 at 05:06 PM.



Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
shell script, Passing string as argument? antis Programming 4 09-07-2007 02:03 AM
simple argument passing tostay2003 Linux - Software 7 09-13-2006 05:11 PM
segfault when passing array[] as argument froboozle Programming 11 06-28-2005 04:06 PM
passing function pointer as argument worldmagic Programming 7 08-04-2004 04:33 PM
PHP Script argument passing error... lokee Linux - Software 5 04-24-2003 10:42 AM > Forums > Non-*NIX Forums > Programming

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

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration