next up previous contents
Next: Text Up: Further MATLAB Previous: Efficiency TestingTimes and

Polynomials

A polynomial is represented by a vector of the coefficients, constant last. E.g. tex2html_wrap_inline2831 becomes [2 8 -7 0].

Polynomial multiplication is performed by conv(p, q) (which convolves the vectors). Division is available with [q, r] = deconv(denom, numer), which sets the quotient q and remainder r such that denom = q * numer + r. Polynomials of equal degree can be added with +, but polynomials of unequal degree cannot be add directly; the lesser must be padded with zeros in front.

polyfit(x, y, n) finds the polynomial p in x of degree n that best fits y = p(x) in the least-squares sense. polyval(p, x) evaluates the polynomial p at the point x, elementwise, if x is a matrix. These functions can also give error estimates; see the help entries. polyvalm(p, m) performs polynomial evaluation on a matrix (i.e. as a matrix, not elementwise). For some other curve-fitting capabilities see curvefit.

You can find the roots of a polynomial with roots and its derivative with polyder. The characteristic polynomial of a matrix M (i.e. det(M - lambda)) is given by poly(M). See help polyfun for further polynomial and interpolation functions.



sepherke
Sat Mar 21 21:42:28 EST 1998