Convolution:
Example 1:
x1 = [3 1 -2 5];
n1 = -1:2; % generating index
x2 = [2 1 3 6];
n2 = -2:1;
% Convolution
y1 = conv(x1, x2)
% Calculate index for convolution result
kmin = n1(1) + n2(1) % left edge of convolved result
kmax = n1(end) + n2(end) % right edge of convolved result
k1 = kmin:kmax % generating index of the result
% Plotting
subplot(3,1,1)
stem(n1, x1)
subplot(3,1,2)
stem(n2, x2)
subplot(3,1,3)
stem(k1,y1)
Example 2:
x1 = [4 2 6 3 8 1 5];
n1 = -2:4; % generating index
x2 = [3 8 6 9 6 7];
n2 = -4:1;
% Convolution
y1 = conv(x1, x2)
% Calculate index for convolution result
kmin = n1(1) + n2(1) % left edge of convolved result
kmax = n1(end) + n2(end) % right edge of convolved result
k1 = kmin:kmax % generating index of the result
% Plotting
subplot(3,1,1)
stem(n1, x1)
subplot(3,1,2)
stem(n2, x2)
subplot(3,1,3)
stem(k1,y1)
Task:
1.Solve the problem of example 2 by hand calculation
2. Find out the linear convolution of x(n)=[1 -2 0 2 1] and h(n)=[2 0 -3 -2 1 1].