EXP.
NO: 2a
LINEAR CONVOLUTION OF TWO SEQUENCES
AIM: To obtain Linear Convolution of two finite length sequences
Software: MATLAB R2013a
THEORY: Convolution is a mathematical operation used to express the relation between input and
output of an LTI system. It relates input, output and impulse response of an LTI system as
y(n)=x(n)∗h(n)
Where y (n) = output of LTI
x (n) = input of LTI
h (n) = impulse response of LTI Discrete Convolution
y(n)=x(n)∗h(n)
By using convolution we can find zero state response of the system.
Algorithm:
Step I: Give input sequence x[n].
Step II: Give impulse response sequence h(n)
Step III: Find the convolution y[n] using the matlab command conv.
Step IV: Plot x[n],h[n],y[n]
PROGRAM:
clc;
clear all;
close all;
x1=input('Enter the first sequence x1(n) = ');
x2=input('Enter the second sequence x2(n) = ');
L=length(x1);
M=length(x2);
N=L+M-1;
yn=conv(x1,x2);
disp(‘The values of yn are= ‘);
disp(yn); n1=0:L-1;
subplot(311);
stem(n1,x1);
grid on;
xlabel('n1--->');
ylabel('amplitude--->');
title('First sequence');
n2=0:M-1;
subplot(312);
stem(n2,x2);
grid on;
xlabel('n2--->');
ylabel('amplitude--->');
title('Second sequence');
n3=0:N-1;
subplot(313);
stem(n3,yn);
grid on;
xlabel('n3--->');
ylabel('amplitude--->');
title('Convolved output');
Output: Enter the first sequence x1(n) = [1 2 3 4 5]
Enter the second sequence x2(n) = [5 8 3 5 4 6]
The values of yn are= 5 18 34 55 80 81 59 59 44 30
[Link]: 2b
CIRCULAR CONVOLUTION OF TWO SEQUENCES
AIM: To obtain Circular Convolution of two finite length sequences
Software: MATLAB
THEORY:
Multiplication of two sequences in frequency domain is called as circular convolution.
Circular Convolution is calculated as
Algorithm:
Step I : Give first input sequence x1[n].
Step II : Give second input sequence x2[n].
Step III: Find circular convolution using the matlab command cconv.
Step IV: Plot x1[n], x2[n], y[n]. Step V: Display the results
PROGRAM:
clc;
clear all;
close all;
x1=input('Enter the first sequence x1(n) = ');
x2=input('Enter the second sequence x2(n) = ');
L=length(x1);
M=length(x2);
N=max(L,M);
yn=cconv(x1,x2,N);
disp('The values of yn are= ');
disp(yn);
n=0:N-1;
subplot(311);
stem(n,x1);
grid on;
xlabel('n--->');
ylabel('amplitude--->');
title('First sequence');
subplot(312);
stem(n,x2);
grid on;
xlabel('n--->');
ylabel('amplitude--->');
title('Second sequence');
subplot(313);
stem(n,yn);
grid on;
xlabel('n--->');
ylabel('amplitude--->');
title('Circular Convolution output');
Output: Enter the first sequence
x1(n) = [1 2 3 4 5]
Enter the second sequence
x2(n) = [1 2 1 2 1]
The values of yn are= 23 20 22 19 21
Output Wave forms: