Polynomials

If

>> polyval(v,x)calculates the value of the polynomial represented by

>> polyval([1 -2 0 1],[1 2 3 4]) ans = [0 1 10 33]i.e., 0, 1, 10, 33 are the values of the polynomial

Very often polynomial data fitting is used to fit a polynomial function through measurement data. The data fitting is done by means of the so-called least squares method. In this method, one attempts to generate a

(2.1) |

where the

`polyfit(x,y,n)`

. Here,
`>> coeff = polyfit(y,x,1)`

results in a linear approximation

`>> a0 = coeff(1)`

`>> a1 = coeff(2)`

.
To evaluate this data fitting, you can use the command

`polyval`

again. For example, calculate some points of the line for
xp = 0:0.1:7; yp = polyval(coeff,xp);

Esteur 2010-03-22