Polynomial Functions É 153
5.6 Polynomial Functions
In MATLAB, a polynomial is represented by a vector. To create a polynomial in MATLAB,
simply enter each coefficient of the polynomial into the vector in descending order. For instance,
consider the following polynomial:
fx xx
1315
43 2
()=+ −−+
To enter this into MATLAB, just enter it as a vector in the following manner:
>> f1x = [1 3 -15 -2 9]
f1x = 1 3 -15 -2 9
MATLAB interprets a vector of length n + 1 as an nth order polynomial. Thus, if a polynomial
is missing any coefficients, one must enter zeros in the appropriate place in the vector. For
example, if
fx
()=+
, then it would be represented in MATLAB as
2(
= [1 0 2 0 0].
The value of a polynomial f(x) can be evaluated at x = k using ...