Programming |

This example implements a MATLAB data type for polynomials by defining a new class called polynom. The class definition specifies a structure for data storage and defines a directory (`@polynom`

) of methods that operate on polynom objects.

**Polynom Data Structure**

The polynom class represents a polynomial with a row vector containing the coefficients of powers of the variable, in decreasing order. Therefore, a polynom object `p`

is a structure with a single field, `p.c`

, containing the coefficients. This field is accessible only within the methods in the `@polynom`

directory.

**Polynom Methods**

To create a class that is well behaved within the MATLAB environment and provides useful functionality for a polynomial data type, the polynom class implements the following methods:

- A constructor method
`polynom.m`

- A polynom to double converter
- A polynom to char converter
- A
`display`

method - A
`subsref`

method - Overloaded
`+`

, -, and`*`

operators - Overloaded
`roots`

,`polyval`

,`plot`

, and`diff`

functions

Overloading Functions | The Polynom Constructor Method |

© 1994-2005 The MathWorks, Inc.