I am trying to convert some data from wikipedia to octave and I ran into this problem.
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)
plot(x,y,'x',x,y,x,y2,x,y3)
**********************************************
poly fit should return the polynomial in P
But when i use it in polyval it is obviously wrong.
but polyfit also returns the new calculated y values in S.yf.
S.yf look correct ut P seems to be wrong.
I get
which is y=x*1.841 + 7.5009
and this is obviously wrong.