p2 =
2*x^4 + 3*x^2 + 2*x - 7
Find the roots of the polynomial by passing the coefficients to the roots function.
roots(p1.coef)
ans =
2.0946 + 0.0000i
-1.0473 + 1.1359i
-1.0473 - 1.1359i
Add the two polynomials p1 and p2.
MATLAB calls the plus method defined for the DocPolynom class when you add two
DocPolynom objects.
p1 + p2
ans =
2*x^4 + x^3 + 3*x^2 - 12
DocPolynom Class Synopsis
Example Code Discussion
classdef DocPolynom Value class that implements a
data type for polynomials.
properties
coef
end
Vector of polynomial coefficients
[highest order ... lowest order]
methods For general information about
methods, see “Ordinary
Methods” on page 9-8
19 Defining Custom Data Types