MATLAB Object-Oriented Programming

(Joyce) #1

DocPolynom Class Properties


Name Class Default Description
coef double [] Vector of polynomial coefficients
[highest order ... lowest order]

The following table summarizes the methods for the DocPolynom class.


DocPolynom Class Methods


Name Description
DocPolynom Class constructor
double Converts a DocPolynom object to a double (that is, returns its
coefficients in a vector)
char Creates a formatted display of the DocPolynom object as powers
of x and is used by the disp method
disp Determines how MATLAB displays DocPolynom objects on the
command line
subsref Enables you to specify a value for the independent variable as a
subscript, access the coef property with dot notation, and call
methods with dot notation.
plus Implements addition of DocPolynom objects
minus Implements subtraction of DocPolynom objects
mtimes Implements multiplication of DocPolynom objects

Using the DocPolynom Class


The following examples illustrate basic use of the DocPolynom class.


Create DocPolynom objects to represent the following polynomials. The argument to the


constructor function contains the polynomial coefficients and


.

p1 = DocPolynom([1 0 -2 -5])


p1 =
x^3 - 2*x - 5


p2 = DocPolynom([2 0 3 2 -7])


Representing Polynomials with Classes
Free download pdf