Programming |

**The Polynom Constructor Method**

Here is the polynom class constructor, `@polynom/polynom.m`

.

`function p = polynom(a)`

`%POLYNOM Polynomial class constructor.`

`% p = POLYNOM(v) creates a polynomial object from the vector v,`

`% containing the coefficients of descending powers of x.`

if nargin == 0 p.c = []; p = class(p,`'`

polynom`'`

); else`if isa(a,'polynom')`

`p = a;`

`else`

`p.c = a(:).';`

`p = class(p,'polynom');`

`end`

**Constructor Calling Syntax**

You can call the polynom constructor method with one of three different arguments:

- No input argument -- If you call the constructor function with no arguments, it returns a polynom object with empty fields.
- Input argument is an object -- If you call the constructor function with an input argument that is already a polynom object, MATLAB returns the input argument. The
`isa`

function (pronounced "is a") checks for this situation. - Input argument is a coefficient vector -- If the input argument is a variable that is not a polynom object, reshape it to be a row vector and assign it to the
`.c`

field of the object's structure. The`class`

function creates the`polynom`

object, which is then returned by the constructor.

An example use of the `polynom`

constructor is the statement

This creates a polynomial with the specified coefficients.

Example -- A Polynomial Class | Converter Methods for the Polynom Class |

© 1994-2005 The MathWorks, Inc.