Convolving Two Signals Using Matlab.
22 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuesta aceptada
Jaya
el 4 de Dic. de 2021
Editada: Jaya
el 4 de Dic. de 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).
Más respuestas (0)
Ver también
Categorías
Más información sobre 2-D and 3-D Plots en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!