Products & Services Solutions Academia Support User Community Company

Learn more about MATLAB   

Evaluating Polynomials

The polyval function evaluates a polynomial at a specified value. To evaluate p at s = 5, use

polyval(p,5)

ans =
   110

It is also possible to evaluate a polynomial in a matrix sense. In this case p(s) = x cubed minus 2 times x minus 5 becomes p(x) = x cubed minus 2 X minus 5 I , where X is a square matrix and I is the identity matrix. For example, create a square matrix X and evaluate the polynomial p at X:

X = [2 4 5; -1 0 3; 7 1 5];
Y = polyvalm(p,X)

Y =
   377   179   439
   111    81   136
   490   253   639
  


Recommended Products

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.

 © 1984-2009- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS