help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: polyfit -> polyval problem


From: Ben Abbott
Subject: Re: polyfit -> polyval problem
Date: Wed, 22 Jun 2011 09:21:20 -0400

On Jun 22, 2011, at 9:16 AM, Sergei Steshenko wrote:

> Hello,
> 
> I can't figure out what I an doing wrong in the following example:
> 
> "
> octave:42> [p, s, mu] = polyfit ((1:10)(:), 2 * (1:10)(:), 1);
> octave:43> p
> p =
> 
>    6.0553   11.0000
> 
> octave:44> polyval(p, 1:10)
> ans =
> 
>   17.055   23.111   29.166   35.221   41.277   47.332   53.387   59.442   
> 65.498   71.553
> 

I think the problem is with the syntax you're using for polyval. If "mu" is an 
output for polyfit(), then it must be used as an input for polval().

octave:3>  [p, s, mu] = polyfit ((1:10)(:), 2 * (1:10)(:), 1);
octave:4> polyval(p, 1:10, [], mu)
ans =

    2.0000    4.0000    6.0000    8.0000   10.0000   12.0000   14.0000   
16.0000   18.0000   20.0000

Ben







reply via email to

[Prev in Thread] Current Thread [Next in Thread]