polyfit
polynomial · scripts/polynomial/polyfit.m
P = polyfit (X, Y, N)
[P, S] = polyfit (X, Y, N)
[P, S, MU] = polyfit (X, Y, N) -- least squares polynomial fit.
P (a row, highest power first) minimises the 2-norm of Y - polyval (P, X)
over polynomials of degree N. S holds the triangular factor R of the QR
decomposition of the Vandermonde matrix, the degrees of freedom DF, the
residual norm NORMR and (unadjusted) RSQUARED. With a third output the
fit is made on the scaled abscissa (X - MU(1)) / MU(2),
MU = [mean(X); std(X)].