# Convolving Two Signals Using Matlab.

조회 수: 20(최근 30일)
cikalekli 2021년 12월 4일
편집: Jaya 2021년 12월 4일
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 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 2021년 12월 4일
Thank you so much for your response, I will do it what you have said to me.

댓글을 달려면 로그인하십시오.

### Community Treasure Hunt

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

Start Hunting!