Skip to content

# polyval

Evaluating Polynomial

### polyval(p, x)

• It evaluates a polynomial at each element of x. The coefficients of the polynomial are contained in p.
• x should be an array.
• p should be a vector containing coefficents of a polynomial; p(1) corresponds to the highest order term.
• p should be non-empty.
• If p is a logical or character array, it is converted to a double array before executing the function.
• The output has the same size as x.

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.