0% found this document useful (0 votes)
20 views

Overlap Add Method: Input Input Input Input Modulo

The document describes two methods for computing linear convolution: the overlap add method and the overlap save method. The overlap add method divides the longer sequence into blocks, zeros pads if needed, takes the FFT of each block and the filter, multiplies them, and sums the results. The overlap save method similarly divides the longer sequence into blocks, takes the FFT of each block and filter, multiplies them, and saves the valid results without summing.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views

Overlap Add Method: Input Input Input Input Modulo

The document describes two methods for computing linear convolution: the overlap add method and the overlap save method. The overlap add method divides the longer sequence into blocks, zeros pads if needed, takes the FFT of each block and the filter, multiplies them, and sums the results. The overlap save method similarly divides the longer sequence into blocks, takes the FFT of each block and filter, multiplies them, and saves the valid results without summing.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Overlap Add Method

clc
clear
disp('Consider longer sequence as x(n) and shorter one as h(n)');
l=input('Enter the number elements in x(n)');
x=input('Enter x1(n):');
N=input('Enter the number elements in h(n)');
h=input('Enter h(n):');
k=modulo(l,N);
if k~=0 then
for d=(1):N-k
x(l+d)=0;
end
end
L=length(x);
m=L/N;
M=L+N-1;
p=1;c=0;
Y=zeros(1,L+N-1);
H=[h,zeros(1,N-1)];
for a=1:m
x1=zeros(N);
j=1;
for b=p:p+N-1;
x1(j)=x(b);
j=j+1;
end
X=[x1',zeros(1,N-1)];
H1=fft(H);
X1=fft(X);
y=H1.*X1;
y1=fft(y,1);
p=p+N;
y2=circshift([y1,zeros(1,(m-1)*N)],c*N);
c=c+1;
Y=Y+y2;
end
disp('The linear convolution Y(n) is:');
disp(Y);

Overlap Save Method


clc
clear
disp('Consider longer sequence as x(n) and shorter one as h(n)');
n=input('Enter the number elements in x(n)');
x=input('Enter x1(n):');
M=input('Enter the number elements in h(n)');
h=input('Enter h(n):');
N=input('Enter the size of DFT to be performed');
L=N-M+1;
H=[h,zeros(1,L-1)];
X=[zeros(1,M-1),x,zeros(1,M-1)];
Y=zeros(1,n+M-1);
a=length(X);
p=1;i=1;
while p+N-1<=a
x1=zeros(N);
j=1;
for b=p:p+N-1;
x1(j)=X(b);
j=j+1;
end
H1=fft(H);
X1=fft(x1');
y=H1.*X1;
y1=fft(y,1);
p=p+L;
c=0;
for c=M-1:N-1
Y(i)=y1(c+1);
i=i+1;
end
end
disp('The linear convolution Y(n) is:');
disp(Y);

You might also like