polyfit - Polynomial curve fitting
Syntax
p = polyfit(x,y,n) [p,S] = polyfit(x,y,n) [p,S,mu] = polyfit(x,y,n)
Description
p = polyfit(x,y,n) finds the coefficients of a polynomial p(x) of degree n that fits the data, p(x(i)) to y(i) , in a least squares sense. The result p is a row vector of length n+1 containing the polynomial coefficients in descending powers:
[p,S] = polyfit(x,y,n) returns the polynomial coefficients p and a structure S for use with polyval to obtain error estimates or predictions. Structure S contains fields R , df , and normr , for the triangular factor from a QR decomposition of the Vandermonde matrix of x , the degrees of freedom, and the norm of the residuals, respectively. If the data y are random, an estimate of the covariance matrix of p is (Rinv*Rinv')*normr^2/df , where Rinv is the inverse of R . If the errors in the data y are independent normal with constant variance, polyval produces error bounds that contain at least 50...
Machine Vision & Image Processing