Linear Convolution | Scigyan

Linear Convolution

Matlab program to find Linear Convolution of given signals.
Linear Convolution: If x(n) is a sequence of N1 number of samples and h(n) with N2 number of samples, after convolution y(n) will have N=N1+N2-1 samples.
It can be used to find the response of a linear filter.
Zero padding is not necessary to find the response of a linear filter.

Matlab code

clc;
clear all; close all;
x=input('Enter the 1st Sequence x[n]='); h=input('Enter the 2nd Sequence h[n]=');
x1=input('Define the Initial Position of x[n] in Time(X) axis='); 
h1=input('Define the Initial Position of h[n] in Time(X) axis='); 
N1=length(x);
N2=length(h);
x2=x1+(N1-1); % End Position of x[n] in Time(X) axis 
h2=h1+(N2-1); % End Position of h[n] in Time(X) axis 
y1=x1+h1;
y2=x2+h2; y=conv(x,h);
disp('The Resultant Signal y[n]=');disp(y);

subplot(3,1,1);
stem(x1:x2,x);
title('(a) Input Signal x[n] ');
xlabel('Time-->'); ylabel('Amplitude');

subplot(3,1,2);
stem(h1:h2,h);
title('(b) Input Signal h[n]');
xlabel('Time-->'); ylabel('Amplitude');

subplot(3,1,3);
stem(y1:y2,y);
title('(c) Convolved Output Signal y[n]'); xlabel('Time-->');
ylabel('Amplitude');

Command window

Enter the 1st Sequence x[n] = [1 2 3 4]
Enter the 2nd Sequence h[n] = [1 1 1 1 1]
Define the Initial Position of x[n] in Time(X) axis = 2 
Define the Initial Position of h[n] in Time(X) axis = 0 T
he Resultant Signal y[n] = 1 3 6 10 10 9 7 4

Figure window

Linear-Convolution
No comments:
Post a Comment

Related Posts Plugin for WordPress, Blogger...