https://www.mathworks.com/help/matlab/ref/conv.html?s_tid=gn_loc_drop
conv
Convolution and polynomial multiplication
Description
w = conv( returns the convolution of vectors u,v)u and v. If u and v are vectors of polynomial coefficients, convolving them is equivalent to multiplying the two polynomials.
Examples
Polynomial Multiplication via Convolution
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 .
Vector Convolution
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.
Central Part of Convolution
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.