MATLAB: Using functions relating polynomial

homeworkhow to use functions

Hi guys,
I would like to develop a function called poly_prod which determines the product of two polynomials. Let say P=[1 1 -7 -15] and Q=[3 -1 2], and when I use poly_prod(P,Q), the following answer is expected.
First Q(1)*P, which is [3 3 -21 -45]
Second Q(2)*P, which is [-1 -1 7 15]
Third Q(3)*P, which is [2 2 -14 -30]
Then it should be added like this:
[3 3 -21 -45 0 0] + [0 -1 -1 7 15] + [0 0 2 2 -14 -30]
and the final answer should show: [3 2 -20 -36 1 -30]
Thank you.

Best Answer

result = conv(P,Q)