Convolving Two Signals Using Matlab.
18 次查看(过去 30 天)
显示 更早的评论
Hi, I have a question about convolution of 2 signals.
I shared my code at the end of the question.
I am wondering if I did it right?
Here is my code:
clear;
clc;
close;
x = [1 0 3 1 2 -1 0 0]; % Input signal zero-padded to length 8
xm2 = [0 0 1 0 3 1 2 -1]; % Shifted input signal x[n-2]
h = [2 0 2]; % Impulse response to length 3
n = 0:9; % "time" values for x-axis of plot 8+3-1=10 --> means from 0 to 9
y1 = conv(x,h); % Make y1[n] = x[n] * h[n]
y2 = conv(xm2,h); % Make y2[n] = x[n-2] * h[n]
subplot(2,1,1); % Make a 2x1 array of graphs and make the first graph the "current" one
stem(n,y1); % Plot y1 against n
title('y_1[n] = x[n] * h[n]'); % Title for top graph
xlabel('n'); % X-axis label for top graph
ylabel('y_1[n]'); % Y-axis label for top graph
subplot(2,1,2); % Select the second graph as "current"
stem(n,y2); % Plot y2 against n
title('y_2[n] = x[n-2] * h[n]'); % Title for bottom graph
xlabel('n'); % X-axis label for bottom graph
ylabel('y_2[n]'); % Y-axis label for bottom graph
0 个评论
采纳的回答
Jaya
2021-12-4
编辑:Jaya
2021-12-4
The steps and the answer looks right to me. I also used an online convolution calculator to verify this. I didn't do by hand as I didn't have time.
But you can do it on paper as the signals are just shifted deltas. And show the verification for your class work (if it is required).
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!