obj.coef = val(ind(1):end);
else
obj.coef = val;
end
end
end
Convert DocPolynom Objects to Other Types
The DocPolynom class defines two methods to convert DocPolynom objects to other
classes:
- double — Converts to the double numeric type so functions can perform
mathematical operations on the coefficients. - char — Converts to characters used to format output for display in the command
window
The Double Converter
The double converter method for the DocPolynom class simply returns the coefficient
vector:
methods
function c = double(obj)
c = obj.coef;
end
end
For the DocPolynom object p:
p = DocPolynom([1 0 -2 -5]);
the statement:
c = double(p)
returns:
c=
1 0 -2 -5
which is of class double:
Representing Polynomials with Classes