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'
); elseif 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:
isa
function (pronounced "is a") checks for this situation.
.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.