Representing Polynomials with Classes
In this section...
“Object Requirements” on page 19-2
“DocPolynom Class Members” on page 19-2
“DocPolynom Class Synopsis” on page 19-4
“The DocPolynom Constructor” on page 19-13
“Remove Irrelevant Coefficients” on page 19-14
“Convert DocPolynom Objects to Other Types” on page 19-15
“Overload disp for DocPolynom” on page 19-17
“Display Evaluated Expression” on page 19-18
“Redefine Indexed Reference” on page 19-19
“Define Arithmetic Operators” on page 19-21
Object Requirements
This example implements a class to represent polynomials in the MATLAB language. The
design requirements are:
- Value class behavior—a polynomial object should behave like MATLAB numeric
variables when copied and passed to functions. - Specialized display and indexing
- Objects can be scalar only. The specialization of display and indexing functionality
preclude normal array behavior. - Arithmetic operations
- Double converter simplifying the use of polynomial object with existing MATLAB
functions that accept numeric inputs.
DocPolynom Class Members
The class definition specifies a property for data storage and defines a folder
(@DocPolynom) that contains the class definition.
The following table summarizes the properties defined for the DocPolynom class.
19 Defining Custom Data Types