Convolution and polynomial multiplication
w = conv(u,v)
w = conv(u,v,shape)
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
length(u)+length(v)-1, which in this example is
Create two vectors. Find the central part of the convolution of
v that is the same size as
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.
u,v— Input vectors
Input vectors, specified as either row or column vectors. The
v can be different
lengths or data types.
v are of type
then the output is of type
inputs to type
double and returns type
Complex Number Support: Yes
shape— Subsection of convolution
Subsection of the convolution, specified as
Full convolution (default).
Central part of the convolution of the same size as
Only those parts of the convolution that are computed
without the zero-padded edges. Using this option,
The convolution of two vectors,
represents the area of overlap under the points as
u. Algebraically, convolution is the same
operation as multiplying polynomials whose coefficients are the elements
m = length(u) and
n = length(v) .
w is the vector of length
The sum is over all the values of
lead to legal subscripts for
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)
This function supports tall arrays with the limitation:
be column vectors.
B cannot be a tall array.
For more information, see Tall Arrays.
For information about C/C++ code generation limitations, see Variable-Sizing Restrictions for Code Generation of Toolbox Functions (MATLAB Coder).