MATLAB conv functiorn Let f(n)- u(n) - u(n -5) g(n) = r(n)--2 r(n-5) + r(n-10) w
ID: 3184308 • Letter: M
Question
MATLAB conv functiorn Let f(n)- u(n) - u(n -5) g(n) = r(n)--2 r(n-5) + r(n-10) where r(n) := n a(n) In MATLAB, use theconv function to compute the following convolutions. Use the stem function to plot the results. Be aware about the lengths of the signals. Make sure the horizontal axes in your plots are correct (a) f(n)» f(n) (b) f(n)» f(n)*f(n) (c) f(n). g(n) (d) g(n) * (n) (e) g(n) »g(n) Comment on your observations: Do you see any relationship between f(n)*f (n) and g(n) ? Compare f(n) with f(n)*f(n) and with f(n) - f(n)f(. What happens as you repeatedly convolve this signal with itself? Use the commands title, xlabel, ylabel to label the axes of your plotsExplanation / Answer
%MATLAB Code
f = @(n) heaviside(n) - heaviside(n-5);
g = @(n) n*heaviside(n) - 2*(n-5)*heaviside(n-5) + (n-10)*heaviside(n-10);
del_n = @(n) dirac(n);
e = -10:10;
F = zeros(1,length(e));
G = zeros(1,length(e));
Del_n = zeros(1,length(e));
for w = 1:length(e)
F(w) = f(e(w));
G(w) = g(e(w));
Del_n(w) = del_n(e(w));
end
conv_1 = conv(F,F);
conv_2 = conv(conv_1,F);
conv_3 = conv(F,G);
conv_4 = conv(G,Del_n);
conv_5 = conv(G,G);
figure;
stem(conv_1)
title('conv(F,F)')
xlabel('n')
ylabel('conv(F,F)')
figure;
stem(conv_2)
title('conv(conv_1,F)')
xlabel('n')
ylabel('conv(conv_1,F)')
figure;
stem(conv_3)
title('conv(F,G)')
xlabel('n')
ylabel('conv(F,G)')
figure;
stem(conv_4)
title('conv(G,Del_n)')
xlabel('n')
ylabel('conv(G,Del_n)')
figure;
stem(conv_5)
title('conv(G,G)')
xlabel('n')
ylabel('conv(G,G)')