Exp7 Watermark

Download as pdf or txt
Download as pdf or txt
You are on page 1of 8

EXPERIMENT-7

AIM :-

Develop radix-2 butterfly FFT (Decimation in Time) algorithm for the computation of N-point
DFT.

THEORY:-

Getting to Know the FFT


What is the FFT? FFT = Fast Fourier Transform. The FFT is a faster version of the Discrete
Fourier Transform (DFT). The FFT utilizes some clever algorithms to do the same thing as the
DTF, but in much less time.

Ok, but what is the DFT?


The DFT is extremely important in the area of frequency (spectrum)analysis because it takes a
discrete signal in the time domain and transforms that signal into its discrete frequency
domain representation. Without a discrete-time to discrete-frequency transform we would
not be able to compute the Fourier transform with a microprocessor or DSP based system. It is
the speed and discrete nature of the FFT that allows us to analyze a signal's spectrum with
Matlab or in real- time on the SR770

The Laplace transform is used to find a pole/zero representation of a continuous-time signal or


system, x(t), in the s-plane. Similarly, The z transform is used to ¯nd a pole/zero representation
of a discrete-time signal or system, x[n], in the z-plane.
The continuous-time Fourier transform (CTFT) can be found by evaluating the Laplace trans-
form at s = j The discrete-time Fourier transform (DTFT) can be found by evaluating the z
transform at z = e-j

Understanding the DFT


How does the discrete Fourier transform relate to the other transforms? First of all, the DFT is
NOT the same as the DTFT. Both start with a discrete-time signal, but the DFT produces a
discrete frequency domain representation while the DTFT is continuous in the frequency
domain. These two transforms have much in common, however. It is therefore helpful to have
a basic understanding of the properties of the DTFT.
Periodicity: The DTFT, X(e-j ), is periodic. One period extends from f = 0 to fs, where
fs is the sampling frequency. Taking advantage of this redundancy, The DFT is only defined in
the region between 0 and fs.

Symmetry: When the region between 0 and fs is examined, it can be seen that there is even
symmetry around the center point, 0.5fs, the Nyquist frequency. This symmetry adds
redundant information. Figure 1 shows the DFT (implemented with Matlab's FFT function) of a
cosine with a frequency one tenth the sampling frequency. Note that the data between 0.5fs
and fs is a mirror image of the data between 0 and 0.5fs

IN LAB EXERCISE:-

Write your own MATLAB function to compute DFT using FFT DIT, FFT DIF, FFT (in built
function)
%decimation in time
x = input('Enter the input sequence :');
l = length(x);
k = 0;
while((2^k)<1)
k = k+1;
end
x1 = [x zeros(1,(2^k)-1)];
n = length(x1);
y = zeros(1,n);
j = 1;
for k = 1:2:n;
xe(j) = x1(k);
j=j+1;
end
j = 1;
for k = 2:2:n;
xo(j) = x1(k);
j=j+1;
end
for k=1:1:n;
for j=1:1:(n/2);
y(k) = y(k) + xe(j)*exp(-4*pi*1i*(j-1)*(k-1)/n) + exp(-2*pi*1i*(k-1)/n)*xo(j)*exp(-
4*pi*1i*(j-1)*(k-1)/n);
end
end
axis tight
subplot(2,1,1)
stem(x)
xlabel("Samples [n]")
ylabel('Amplitude [n]')
title('input sequence x[n] 22102205')
subplot(2,1,2)
stem(abs(y))
xlabel("Freq index [k]")
ylabel('Magnitude |X[k]|')
title('DFT magnitude of x[n] 22102205')

%Decimation in frequency
X = input('Enter the input sequence :');
l = length(X);
k = 0;
while((2^k)<l)
k = k+1;
end
X11 = [X zeros(1,(2^k)-l)];
n = length(X11);
Y = zeros(1,n);
X1 = zeros(1,n/2);
X2 = zeros(1,n/2);

for j = 1:2:n
X1((j+1)/2) = X11(j);
end

for j = 2:2:n
X2(j/2) = X11(j);
end

for k = 1:n
for j = 1:n/2
Y(k) = Y(k) + (X1(j) + exp(-1i*pi*(k-1))*X2(j))*exp(-2i*pi*(j-1)*(k-1)/n); %
Corrected formula
end
end

subplot(2,1,1)
stem(X)
xlabel("Samples [n]")
ylabel('Amplitude [n]')
title('input sequence X[n] 22102205')

subplot(2,1,2)
stem(abs(Y))
xlabel("Freq index [k]")
ylabel('Magnitude |X[k]|')
title('DFT magnitude of X[n] 22102205')

%using inbuilt function


x=input('Enter the input sequence: ');
N=input('Enter the length of FFT: ');
X=fft(x,n);
axis tight
subplot(2,1,1)
stem(x)
xlabel('Samples [n]')
ylabel('Amplitude x[n]')
title('Input sequence 22102205')
subplot(2,1,2)
stem(abs(y))
xlabel('Freq index [k]')
ylabel('Magnitude X[k]')
title('DFT magnitude of x[n] 22102205')

OUTPUT:-
1.
2.
POSTLAB EXERCISE :-

Fs = 8000;
T = 1/Fs;
l = 240;
t = (0:l-1)*T;

x1 = 5*cos(2*pi*500*t);
x2 = 5*cos(2*pi*1200*t + 0.25*pi);
x3 = 5*cos(2*pi*1800*t + 0.5*pi);

x = x1 + x2 + x3;

subplot(4,1,1);
stem(t, x1);
title('x1(t) ANKIT KESARI 22102205');
xlabel('Time (s)');
ylabel('Amplitude');

subplot(4,1,2);
stem(t, x2);
title('x2(t) ANKIT KESARI 22102205');
xlabel('Time (s)');
ylabel('Amplitude');

subplot(4,1,3);
stem(t, x3);
title('x3(t) ANKIT KESARI 22102205');
xlabel('Time (s)');
ylabel('Amplitude');

subplot(4,1,4);
stem(t, x);
title('x(t) ANKIT KESARI 22102205');
xlabel('Time (s)');
ylabel('Amplitude');

disp(['Total sum of sinusoids: ', num2str(sum(x))]);

OUTPUT:-
Total sum of sinusoids: 3.6149e-13
LEARNING OUTCOME:-

 Understanding the process of DFT using FFT DIT, FFT DIF, FFT (in built function).
 Learning the code required to calculate the above

You might also like