Q: Error in function polyfit() ???

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Q: Error in function polyfit() ???

F.-J. Luecke
Hello,

i used the function polyfit(). I found it is buggy.
I test it with
x=1:10;
y=x;
[p, value] = polyfit(x,y, 4);

and i got strange results.
Is a replacement for polyfit() aviable.

Franz-Josef
Universitaet-GH Siegen
Zentrum fuer Sensorsysteme
F.-J. Luecke
Paul-Bonatz-Strasse 9-11
D-57068 Siegen

Tel.: (049) +271/7402425
Fax : (049) +271/7402336


Reply | Threaded
Open this post in threaded view
|

Re: Q: Error in function polyfit() ???

Mario Storti-4

> Hello,
>
> i used the function polyfit(). I found it is buggy.
> I test it with
> x=1:10;
> y=x;
> [p, value] = polyfit(x,y, 4);
>
> and i got strange results.
> Is a replacement for polyfit() aviable.
>
> Franz-Josef


polyfit() returns the vector of coefficients of the lest square
polynomial of order "n". You should call polyval() afterwards:

> x=1:10;
> y=x;
> p = polyfit(x,y, 4);
> value= polyval(p,4)

Here you compute the Least Squares fitted polynomial of 4rd order and
then eval to obtain the value at x=4.

Cheers,

Mario

%%%%%%<>%%%%%%<>%%%%%%<>%%%%%%<>%%%%%%<>%%%%%%<>%%%%%%<>%%%%%
Mario Alberto Storti               | Fax: (54)(42) 55.09.44 |
Grupo de Tecnologia Mecanica       | Tel: (54)(42) 55.91.75 |
INTEC, Guemes 3450 - 3000 Santa Fe | Home: Gob. Vera 3161   |
Argentina                          |       (54)(42) 55.00.23|
Reply: [hidden email]  |                        |
                http://venus.unl.edu.ar/gtm-eng.html        |