LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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.

Notices


Reply
  Search this Thread
Old 12-21-2009, 03:38 PM   #1
Mike_V
Member
 
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:

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,
 
Old 12-21-2009, 04:04 PM   #2
Mike_V
Member
 
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

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

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


Reply

Tags
matlab


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 01:03 AM
simple argument passing tostay2003 Linux - Software 7 09-13-2006 04:11 PM
segfault when passing array[] as argument froboozle Programming 11 06-28-2005 03:06 PM
passing function pointer as argument worldmagic Programming 7 08-04-2004 03:33 PM
PHP Script argument passing error... lokee Linux - Software 5 04-24-2003 09:42 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:01 AM.

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