Linear Filtering Using Overlap Add and Overlap Save Method: Date: 03/04/2023 Expt No.: 03
Linear Filtering Using Overlap Add and Overlap Save Method: Date: 03/04/2023 Expt No.: 03
Linear Filtering Using Overlap Add and Overlap Save Method: Date: 03/04/2023 Expt No.: 03
Date: 03/04/2023
Expt no.: 03
Aim:
To write a MATLAB Program to demonstrate linear filtering via overlap save and overlap
add methods.
Software used:
MATLAB Interpreter – R2022 b version
Algorithm
1.Let L and M represent the length of the input sequence x(n) and impulse sequence h(n) respectively.
2.Add M-1 leading zeros to the input sequence and L+M-1 trailing zeros to the shorter sequence.
3.Divide the input sequence into segments containing 2M-1 samples. Each segment should contain M-
1 samples from the previous segments.
4.Perform Circular Convolution of each segments with impulse sequence matrix.
5.Discard the first M-1 samples from each of the resultant sequence.
6.Finally concatenate the remaining samples to get the linearly convolved output.
CODE:
clc; clear all; close all;
x=input('Enter the input sequence: ');
N=length(x);
a=0:N-1;
h=input('Enter the impulse sequence: ');
M=length(h);
b=0:M-1;
subplot(3,1,1);
stem(a,x);
Name: U Yuva Kumar
Reg no: 3122 21 3002 115
xlabel('Time');
ylabel('Amplitude');
title('Input sequence')
subplot(3,1,2);
stem(b,h);
xlabel('Time');
ylabel('Amplitude');
title('Impulse sequence');
h=[h zeros(1,M-1)];
L=length(h); % Length of sub-block
H=[H zeros(1,N-n)];
Y=zeros(1,N);
for n=1:N
for m=1:N
j=mod(n-m,N)
j=j+1
Y(n)=Y(n)+X(m)*H(j)
end
end
end
Name: U Yuva Kumar
Reg no: 3122 21 3002 115
Output:
Enter the first sequence :
[3 1 2 2 1 1 5]
[1 1 1]
1 3 6 9 12 15 11 6 0
Inference:
From the above program , we can infer that how the linearly convolved output is obtained by
performing sectioned circular convolution.
Name: U Yuva Kumar
Reg no: 3122 21 3002 115
Algorithm:
1.Let L and M represent the length of the input sequence x(n) and impulse sequence h(n) respectively.
2.Check whether L is an integral multiple of M. If not , zero pad the h(n) sequence so that L=KM.
3.Divide the input sequence x(n) into K non-overlapping segments.
4.Perform Circular Convolution of each segments with impulse sequence matrix.
5.Add the trailing M-1 samples from each of the resultant sequence to the next M-1 leading samples.
6.Finally concatenate the remaining samples to get the linearly convolved output.
Code:
clc; clear all; close all;
x=input('Enter the input sequence: ');
N=length(x);
a=0:N-1;
h=input('Enter the impulse sequence: ');
M=length(h);
b=0:M-1;
subplot(3,1,1);
stem(a,x);
xlabel('Time');
ylabel('Amplitude');
title('Input sequence')
subplot(3,1,2);
stem(b,h);
xlabel('Time');
ylabel('Amplitude');
title('Impulse sequence');
h=[h zeros(1,M-1)];
Name: U Yuva Kumar
Reg no: 3122 21 3002 115
end
y5=sum(y4(:,:));
c=0:length(y5)-1;
subplot(3,1,3);
stem(c,y5);
xlabel('Time');
ylabel('Amplitude');
title('Overlap Add Method');
disp('The overlap add output is:'); disp(y5);
H=[H zeros(1,N-n)];
Y=zeros(1,N);
for n=1:N
for m=1:N
j=mod(n-m,N)
j=j+1
Y(n)=Y(n)+X(m)*H(j)
end
end
end
Output:
2 6 14 23 3 15 0
Name: U Yuva Kumar
Reg no: 3122 21 3002 115
Inference:
From the above program , we can infer that how the linearly convolved output is obtained by
performing sectioned circular convolution.
Result:
Thus, the programs to demonstrate the process of linear filtering using overlap save and overlap add
is executed and the output is verified.
Name: U Yuva Kumar
Reg no: 3122 21 3002 115