Convolution and polynomial multiplication
Create vectors u and v containing the coefficients of the polynomials and .
u = [1 0 1]; v = [2 7];
Use convolution to multiply the polynomials.
w = conv(u,v)
w = 2 7 2 7
w contains the polynomial coefficients for .
Create two vectors and convolve them.
u = [1 1 1]; v = [1 1 0 0 0 1 1]; w = conv(u,v)
w = 1 2 2 1 0 1 2 2 1
The length of w is length(u)+length(v)-1, which in this example is 9.
Create two vectors. Find the central part of the convolution of u and v that is the same size as u.
u = [-1 2 3 -2 0 1 2]; v = [2 4 -1 1]; w = conv(u,v,'same')
w = 15 5 -9 7 6 7 -1
w has a length of 7. The full convolution would be of length length(u)+length(v)-1, which in this example would be 10.
Input vectors, specified as either row or column vectors. The output vector is the same orientation as the first input argument, u. The vectors u and v can be different lengths or data types.
Data Types: double | single
Complex Number Support: Yes
Subsection of the convolution, specified as 'full', 'same', or 'valid'.
Full convolution (default).
Central part of the convolution of the same size as u.
Only those parts of the convolution that are computed without the zero-padded edges. Using this option, length(w) is max(length(u)-length(v)+1,0), except when length(v) is zero. If length(v) = 0, then length(w) = length(u).
The convolution of two vectors, u and v, represents the area of overlap under the points as v slides across u. Algebraically, convolution is the same operation as multiplying polynomials whose coefficients are the elements of u and v.
Let m = length(u) and n = length(v) . Then w is the vector of length m+n-1 whose kth element is
The sum is over all the values of j that lead to legal subscripts for u(j) and v(k-j+1), specifically j = max(1,k+1-n):1:min(k,m). When m = n, this gives
w(1) = u(1)*v(1) w(2) = u(1)*v(2)+u(2)*v(1) w(3) = u(1)*v(3)+u(2)*v(2)+u(3)*v(1) ... w(n) = u(1)*v(n)+u(2)*v(n-1)+ ... +u(n)*v(1) ... w(2*n-1) = u(n)*v(n)