Path: news.mathworks.com!not-for-mail
From: "Eddy " <grotehaas@mathworks.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: input problems: beginner in matlab
Date: Mon, 17 Sep 2007 21:30:06 +0000 (UTC)
Organization: Hoge school arnhem nijmegen
Lines: 51
Message-ID: <fcmrku$g0t$1@fred.mathworks.com>
References: <fcmp9t$3vj$1@fred.mathworks.com> <fcmq56$i9h$1@fred.mathworks.com>
Reply-To: "Eddy " <grotehaas@mathworks.com>
NNTP-Posting-Host: webapp-02-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1190064606 16413 172.30.248.37 (17 Sep 2007 21:30:06 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Mon, 17 Sep 2007 21:30:06 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 482290
Xref: news.mathworks.com comp.soft-sys.matlab:428994



yes that's what I mean,
thanks for your help Travis,

Eddy

"Travis " <traviib.nospam.@yahoo.com> wrote in message
<fcmq56$i9h$1@fred.mathworks.com>...
> Is this what you mean?
> 
> x=[1:1:10];
> funct = input('function to evaluate = ','s');
> to_evaluate = [funct '(x)'];
> y = eval(to_evaluate)
> 
> (should work if you input the correct built in matlab
> function names... ie sin, cos, tan, etc...)
> 
> Might be a better way to do it, but I think that might work.
> 
> --Travis
> 
> "Eddy " <grotehaas@mathworks.com> wrote in message
> <fcmp9t$3vj$1@fred.mathworks.com>...
> > x=[1:1:10]
> > fprintf('please enter a function like sin cos exp etc,\n')
> > fprintf('the calculation performed will be like
> > pfun(funct(x)),\n')
> > fprintf('where funct is your function and x= 0 to 10
> > increment with 1,\n')
> > funct=input('function funct=','s')
> > pfun=funct'(x)'
> > 
> > In the technical course we are starting to learn Matlab for
> > signal processing.
> > So now we have to do all kinds of exercises, and I do
like it.
> > But one thing does not fall in to place.
> > In the above script I prompt for a input from the user and
> > store this in a variable 'funct' the input is as a string.
> > now I want to use what is in the string to doe some
> > computing but this last step will not succeed.
> > So if the input would be sin the computation should be
sin(x)
> > 
> > Can somebody help me with this probably syntax problem??
> > 
> > thanks
> > 
> > Eddy
>