From: Kalani on
"Manjari " <manjarik(a)pdx.edu> wrote in message <hita9a$m1k$1(a)fred.mathworks.com>...
> TideMan <mulgor(a)gmail.com> wrote in message <4b4e81ee-d5e0-445d-bd2e-1934b2b088bb(a)a32g2000yqm.googlegroups.com>...
> > On Jan 15, 2:14 pm, "Manjari Kulkarni" <manja...(a)pdx.edu> wrote:
> > > I would like to make a system call to a Perl script and pass a Matlab variable as an argument.
> > > For example:
> > > arg1 = 100;
> > > arg2 = 200;
> > > I am calling perl script using the function perl ('perlfile.pl', 'arg1','arg2').
> > >
> > > This calls the perl script but literally passes arg1 and arg2 instead of 100 and 200 respectively.  How do I pass variable values using a MATLAB system call?
> > >
> > > -Manjari
> >
> > Just remove the quotes around arg1 and arg2.
>
> I had tried using the method you had described but matlab gives the following error"All input arguments must be valid strings." The sprintf method works. Thank you for your input.
> -Manjari

Hi,
I tried this method and tried to pass two variables with string values.

system('fitD.exe',sprintf('%s',imagePath),sprintf('%s',FileName));

But I get an error message saying Too many input arguments.
How can I solve this problem?
Thanks
From: Manjari Kulkarni on
"Kalani " <ksamarawickrema(a)gmail.com> wrote in message <hsv27v$n5d$1(a)fred.mathworks.com>...
> "Manjari " <manjarik(a)pdx.edu> wrote in message <hita9a$m1k$1(a)fred.mathworks.com>...
> > TideMan <mulgor(a)gmail.com> wrote in message <4b4e81ee-d5e0-445d-bd2e-1934b2b088bb(a)a32g2000yqm.googlegroups.com>...
> > > On Jan 15, 2:14 pm, "Manjari Kulkarni" <manja...(a)pdx.edu> wrote:
> > > > I would like to make a system call to a Perl script and pass a Matlab variable as an argument.
> > > > For example:
> > > > arg1 = 100;
> > > > arg2 = 200;
> > > > I am calling perl script using the function perl ('perlfile.pl', 'arg1','arg2').
> > > >
> > > > This calls the perl script but literally passes arg1 and arg2 instead of 100 and 200 respectively.  How do I pass variable values using a MATLAB system call?
> > > >
> > > > -Manjari
> > >
> > > Just remove the quotes around arg1 and arg2.
> >
> > I had tried using the method you had described but matlab gives the following error"All input arguments must be valid strings." The sprintf method works. Thank you for your input.
> > -Manjari
>
> Hi,
> I tried this method and tried to pass two variables with string values.
>
> system('fitD.exe',sprintf('%s',imagePath),sprintf('%s',FileName));
>
> But I get an error message saying Too many input arguments.
> How can I solve this problem?
> Thanks

Hi Kalani,

Are imagePath and FileName two different variable in which value of the string is stored? if not try passing without using sprintf i.e. system('fitD.exe', 'imagePath' ,'FileName');
-Manjari
From: Walter Roberson on
Manjari Kulkarni wrote:

> Are imagePath and FileName two different variable in which value of the
> string is stored? if not try passing without using
> sprintf i.e.
> system('fitD.exe', 'imagePath' ,'FileName');


No, that will not work. system() only permits a single parameter, and
you are suggesting to pass it three parameters.
From: Manjari Kulkarni on
Walter Roberson <roberson(a)hushmail.com> wrote in message <6ESIn.16178$TL5.10262(a)newsfe24.iad>...
> Manjari Kulkarni wrote:
>
> > Are imagePath and FileName two different variable in which value of the
> > string is stored? if not try passing without using
> > sprintf i.e.
> > system('fitD.exe', 'imagePath' ,'FileName');
>
>
> No, that will not work. system() only permits a single parameter, and
> you are suggesting to pass it three parameters.

Yes. you are correct, system function can returns two parameters [status, result] after executing the system command, but only accepts one parameter, that is why you get the error "too many input arguments".
-Manjari
From: Kalani on
"Manjari Kulkarni" <manjarik(a)pdx.edu> wrote in message <ht1ddt$30r$1(a)fred.mathworks.com>...
> Walter Roberson <roberson(a)hushmail.com> wrote in message <6ESIn.16178$TL5.10262(a)newsfe24.iad>...
> > Manjari Kulkarni wrote:
> >
> > > Are imagePath and FileName two different variable in which value of the
> > > string is stored? if not try passing without using
> > > sprintf i.e.
> > > system('fitD.exe', 'imagePath' ,'FileName');
> >
> >
> > No, that will not work. system() only permits a single parameter, and
> > you are suggesting to pass it three parameters.
>
> Yes. you are correct, system function can returns two parameters [status, result] after executing the system command, but only accepts one parameter, that is why you get the error "too many input arguments".
> -Manjari

I got it to work by writing as system(['fitD.exe ' imagePath ' ' FileName]) Thanks all.