help-octave
[Top][All Lists]

## Re: need help with polyfit and polyval

 From: Dmitri A. Sergatskov Subject: Re: need help with polyfit and polyval Date: Mon, 6 May 2019 10:03:57 -0500

```On Mon, May 6, 2019 at 9:54 AM Dmitri A. Sergatskov
>
> On Mon, May 6, 2019 at 9:50 AM Dmitri A. Sergatskov
> >
> >
> >
> > On Mon, May 6, 2019 at 9:31 AM Doug Stewart <address@hidden> wrote:
> >>
> >> I am trying to convert some data from wikipedia to octave and I ran into
> >> this problem.
> >>
> >> here is the code
> >> **********************************************
> >> data = [    4.0000    3.1000
> >>     5.0000    4.7400
> >>     6.0000    6.1300
> >>     7.0000    7.2600
> >>     8.0000    8.1000
> >>     9.0000    8.1400
> >>    10.0000    8.7400
> >>    11.0000    8.7700
> >>    12.0000    9.1300
> >>    13.0000    9.1400
> >>    14.0000    9.2600  ];
> >>   x = data(:,1);
> >>   y = data(:,2);
> >>   [P, S, MU] = polyfit (x, y, 1)
> >> y3=S.yf
> >> y2=polyval(P,x)

So if you used MU in polifit, you should use it in polyval as well:

y2=polyval(P,x,[],MU)
y2 =

4.7255
5.2805
5.8356
6.3907
6.9458
7.5009
8.0560
8.6111
9.1662
9.7213
10.2764

Dmitri.
--

```