The Math Forum

Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Math Forum » Discussions » Software » comp.soft-sys.matlab

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: How to pass arguments from Shell to Matlab?
Replies: 2   Last Post: Aug 29, 2007 1:05 PM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
David B. Chorlian

Posts: 173
Registered: 12/7/04
Re: How to pass arguments from Shell to Matlab?
Posted: Aug 29, 2007 1:05 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

In <> CLIMATER <> writes:

>Hi folks,

>I tried to pass an argument from my Bourne Shell script to a MATLAB m-
>file that it calls, which sort of looks like the following:

>matlab -nojvm -nosplash < baz.m $foo

>The baz.m is a MATLAB function that I wrote which takes one argument:

>function baz(fn)

>But it turns out baz.m doesn't receive the argument that I mean to
>send to it, which is $foo. Does anyone know how this can be done?

>Thank you very much,

If you are planning to do this often you could try something like
#! /bin/sh
for file
sed "s/$file/fn/" baz.m > bar.m # assumes a single occurance of "fn"
matlab -nojvm -nodisplay < bar.m

I've written a script which does a somewhat more complicated version
of the above method, which I will post if desired.

David B. Chorlian
Neurodynamics Lab SUNY/HSCB

Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© The Math Forum at NCTM 1994-2018. All Rights Reserved.