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

FFT Using Overlap Add Method: 'Enter Input Signal X:' 'Enter Impulse Signal H:'

This document describes using the overlap-add method to calculate the convolution of an input signal x with an impulse response h. It takes the input signals as blocks, calculates the FFT of each block, multiplies the FFTs, calculates the IFFT and sums the overlapping blocks to produce the final output. The code takes the input signals, performs these steps on blocks of size l with nozero zeroes appended, and compares the output to convolution using the inbuilt conv function.

Uploaded by

aa_nilawar
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
57 views

FFT Using Overlap Add Method: 'Enter Input Signal X:' 'Enter Impulse Signal H:'

This document describes using the overlap-add method to calculate the convolution of an input signal x with an impulse response h. It takes the input signals as blocks, calculates the FFT of each block, multiplies the FFTs, calculates the IFFT and sums the overlapping blocks to produce the final output. The code takes the input signals, performs these steps on blocks of size l with nozero zeroes appended, and compares the output to convolution using the inbuilt conv function.

Uploaded by

aa_nilawar
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 3

FFT USING OVERLAP ADD METHOD

x=input('Enter input signal x:');


h=input('Enter impulse signal h:');
lx=length(x);
lh=length(h);
l=input('Enter the block size:');
nb=ceil(lx/l);
disp('Number of blocks ')
z=1;
% xwork=double(nb,l);
nozero=lh-1;
%zeroes to be appended
%xwork1=double(nb+1,l+nozero);
for i=1:nb
for j=1:l
if(z<=lx)
xwork(i,j)=x(z);
xwork1(i,j)=xwork(i,j);
z=z+1;
else
xwork(i,j)=0;
z=z+1;
end
end
end
%appending zeroes =(n-1)
for i=1:nb
for j=l+1:l+nozero
xwork(i,j)=0;
end
end
%appending zero for h
for i=1:lh
xwork1(nb+1,i)=h(i);
end
for i=lh+1:lh+l-1
xwork1(nb+1,i)=0;
end
appending_zeroes=xwork1
%fast fourier transform
xwork1 = xwork1.';
xwork2=fft(xwork1);
xwork2=xwork2.';
%h(k) is on fft of h(n)
FFT=xwork2;
FFT
for i=1:nb
xwork3(i,:)=xwork2(i,:).*xwork2(nb+1,:);
end
on_multiplying_with_impulse=xwork3;
on_multiplying_with_impulse;

xwork3 = xwork3.';
xwork3=ifft(xwork3);
xwork3 = xwork3.';
%completed wid ifft
IFFT=xwork3;
%adding the last n-1
z=1;
IFFT
for i=1:nb-1
%
k=i+1;
nextrowscol=1;
if(i==1.0)
u=1; %temp variable for j
else
u=nozero+1;
end
for j=u:l+nozero;
if(j<=l)
output(z)=xwork3(i,j);
z=z+1;
else
output(z)=xwork3(i,j)+xwork3((i+1),nextrowscol);
nextrowscol=nextrowscol+1;
z=z+1;
end
end
end
title('The output by inbuilt is : ');
a=conv(x,h)
a
title('The output by program is : ');
output

OUTPUT:
Enter input signal x:[1 2 3 4 5 6 7 8 9 10]
Enter impulse signal h:[1 2]
Enter the block size:3
Number of blocks
appending_zeroes =
1
4
7
10
1

2
5
8
0
2

3
6
9
0
0

0
0
0
0
0

FFT =
6.0000
15.0000
24.0000
10.0000
3.0000

-2.0000 - 2.0000i
-2.0000 - 5.0000i
-2.0000 - 8.0000i
10.0000
1.0000 - 2.0000i

2.0000
5.0000
8.0000
10.0000
-1.0000

-2.0000 + 2.0000i
-2.0000 + 5.0000i
-2.0000 + 8.0000i
10.0000
1.0000 + 2.0000i

IFFT =
1 4
7
4 13 16
7 22 25
10 20 0

6
12
18
0

a=
1

10

13

16

19

22

25

28

20

10

13

16

19

22

25

28

20

10

13

16

19

22

25

28

20

a=
1

output =
1

You might also like