# conv

Convolution or polynomial multiplication

### w = conv(u, v)

• u and v are non-empty, and are vectors or scalars. Both u and v can be real or complex.
• w is the result of convoluting u and v.
• If u and v contain coefficients of polynomials $u(x)$ and $v(x)$, respectively, w contain the coefficients of the product $w(x)=u(x)\times v(x)$.

Note

When representing a polynomial by a vector p, p(1) is the highest order term coefficient.

### w = conv(u, v, shape)

• shape should be either 'full', 'valid', or 'same'.
• 'full': It is the same as w = conv(u, v).
• 'same': It gives a vector of length length(u), taken from the middle part of the full convolution w = conv(u, v).
• 'valid': It returns the section of the full convolution w = conv(u, v) which was computed without the zero-padded edges. The output w has the length of max(length(u)-length(v) + 1, 0).

Example 1: Product $w(x)=u(x)v(x)$, where $u(x)=x^2+2x^+3$ and $v(x)=4x^2+5x+6$. Dividing $w(x)$ by $v(x)$ by deconv gives back $u(x)$.

u=[1 2 3];
v=[4 5 6];
w=conv(u,v)
d=deconv(w,v);
d
u

w =
4.000   13.00   28.00   27.00   18.00

d =
1.000   2.000   3.000

u =
1.000   2.000   3.000


Example 2: Results of conv(u,v,'shape') with shape equal to full, same and valid.

u=1:5;
v=6:9;
w=conv(u,v,'full')
w=conv(u,v,'same')
w=conv(u,v,'valid')

w =
Columns 1 through 5:
6.000   19.00   40.00   70.00   100.0
Columns 6 through 8:
94.00   76.00   45.00

w =
40.00   70.00   100.0   94.00   76.00

w =
70.00   100.0