methods
function r = mtimes(obj1,obj2)
obj1 = DocPolynom(obj1);
obj2 = DocPolynom(obj2);
r = DocPolynom(conv(obj1.coef,obj2.coef));
end
end
Using the Arithmetic Operators
Given the DocPolynom object:
p = DocPolynom([1 0 -2 -5]);
The following two arithmetic operations call the DocPolynom plus and mtimes methods:
q = p+1;
r = p*q;
to produce
q =
x^3 - 2*x - 4
r =
x^6 - 4x^4 - 9x^3 + 4x^2 + 18x + 20
Representing Polynomials with Classes