Convolving Two Signals Using Matlab.

26 次查看(过去 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

采纳的回答

Jaya
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).
  1 个评论
cikalekli
cikalekli 2021-12-4
Thank you so much for your response, I will do it what you have said to me.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 2-D and 3-D Plots 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by