<< moc_poly Matlab/Octave Compatibility toolbox moc_polyval >>

Matlab/Octave Compatibility toolbox >> Matlab/Octave Compatibility toolbox > moc_polyfit

moc_polyfit

Return the coefficients of a polynomial

Calling Sequence

p= polyfit (x, y, n)
[p, s] = polyfit (x, y, n)
[p, s, mu] = polyfit (x, y, n)

Parameters

n:

degree (scalar) or logical vector

p:

The polynomial coefficients are returned in a row vector.

s:

The optional output s is a structure

s.R :

Triangular factor R from the QR decomposition.

s.X:

The Vandermonde matrix used to compute the polynomial coefficients.

s.C:

The unscaled covariance matrix, formally equal to the inverse of x'*x, but computed in a way minimizing roundoff error propagation.

s.df:

The degrees of freedom.

s.normr:

The norm of the residuals.

s.yf:

The values of the polynomial for each value of x.

Description

Return the coefficients of a polynomial p(x) of degree n that minimizes the least-squares-error of the fit to the points [x, y]. If n is a logical vector, it is used as a mask to selectively force the corresponding polynomial coefficients to be used or ignored.

The second output may be used by moc_polyval to calculate the statistical error limits of the predicted values. In particular, the standard deviation of pcoefficients is given by sqrt (diag (s.C)/s.df)*s.normr.

When the third output, mu, is present the coefficients, p, are associated with a polynomial in xhat = (x-mu(1))/mu(2). Where mu(1) = mean (x), and mu(2) = stdev (x). This linear transformation of x improves the numerical stability of the fit.

See also

Authors


Report an issue
<< moc_poly Matlab/Octave Compatibility toolbox moc_polyval >>