Programming Previous page   Next Page

Example -- A Polynomial Class

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:

Previous page  Overloading Functions The Polynom Constructor Method Next page

© 1994-2005 The MathWorks, Inc.