How to multiple or divide two polynomials in MatLab? - conv - deconv -- MatLab

How to multiple or divide two polynomials in MatLab? - conv - deconv -- MatLab

How to multiple or divide two polynomials in MatLab?

[Ans]

conv:multiple
deconv:divide

[Description]

conv

Convolution and polynomial multiplication

w = conv(u,v) 

It will return the convolution of vectors u and v. If u and v are vectors of polynomial coefficients, convolving them is equivalent to multiplying the two polynomials.


w = conv(u,v,shape) 

It will return a subsection of the convolution, as specified by shape. For example, conv(u,v,'same') returns only the central part of the convolution, the same size as u, and conv(u,v,'valid') returns only the part of the convolution computed without the zero-padded edges.

deconv

Deconvolution and polynomial division

[q,r] = deconv(u,v) 

It will deconvolve a vector v out of a vector u using long division, and returns the quotient q and remainder r such that u = conv(v,q) + r. If u and v are vectors of polynomial coefficients, then deconvolving them is equivalent to dividing the polynomial represented by u by the polynomial represented by v.

more details on:

conv

Convolution and polynomial multiplication - MATLAB conv (mathworks.com) 

deconv

Deconvolution and polynomial division - MATLAB deconv (mathworks.com)

code

clear
clc
a=[1 1];
b=[1 2];
c=conv(a,b)
%{
output:
c =
1 3 2
%}
%(x+2)*(x+1)=x^2+3*x+1
[Q R]=deconv(c,a)
%{
Q =
1 2
R =
0 0 0
%}
%(x^2+3*x+1)/(x+1)

Comments