Convolving Two Signals Using Matlab.

20 Ansichten (letzte 30 Tage)
cikalekli
cikalekli am 4 Dez. 2021
Bearbeitet: Jaya am 4 Dez. 2021
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

Akzeptierte Antwort

Jaya
Jaya am 4 Dez. 2021
Bearbeitet: Jaya am 4 Dez. 2021
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 Kommentar
cikalekli
cikalekli am 4 Dez. 2021
Thank you so much for your response, I will do it what you have said to me.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu 2-D and 3-D Plots finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by