Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
NCTM or The Math Forum.



Re: How to pass arguments from Shell to Matlab?
Posted:
Aug 29, 2007 1:05 PM


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



