Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

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


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

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 <1188400901.295814.6580@r34g2000hsd.googlegroups.com> CLIMATER <climater@gmail.com> 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:


>#!/bin/sh
>foo="the_name_of_the_file_to_be_processed_in_matlab"
>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,
>David


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

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
chorlian@cns.hscbklyn.edu
davidc@panix.com



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

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.