- It evaluates a polynomial at each element of
x. The coefficients of the polynomial are contained in
xshould be an array.
pshould be a vector containing coefficents of a polynomial;
p(1)corresponds to the highest order term.
pshould be non-empty.
pis a logical or character array, it is converted to a double array before executing the function.
- The output has the same size as
Example 1: Plotting a polynomial.
r=[2 3 4 5]; % Creating a polynomial with roots r p=poly(r); x=linspace(1.8,5.2); % Evaluating the polynomial y=polyval(p,x); plot(x,y,'-o','MarkerSize',2)
Plot is generated.