Sie sind auf Seite 1von 6

COLLEGE OF ENGINEERING AND TECHNOLOGY

B.P.U.T., BHUBANESWAR
Department of ELECTRICAL Engineering
Semester 5th Sheet No. aaaaaa aaaaaaaa

EXPERIMENT NO – 6

AIM OF THE EXPERIMENT:


To perform the FFT (Fast Fourier Transform) of a discrete-time sequence using DIT and DIF method and
plot it using MATLAB.

SOFTWARE REQUIRED:
MATLAB R2017b

THEORY:

A fast Fourier transform (FFT) is an algorithm that samples a signal over a period of time (or space) and divides
it into its frequency components. An FFT algorithm computes the discrete Fourier transform (DFT) of a
sequence, or its inverse (IFFT). Fourier analysis converts a signal from its original domain to a representation
in the frequency domain and vice versa. FFTs can be decomposed using DFTs of even and odd points, which is
called a Decimation-In-Time (DIT) FFT, or they can be decomposed using a first-half/second-half approach,
which is called a “Decimation-In-Frequency” (DIF) FFT.
A twiddle factor, in fast Fourier transform (FFT) algorithms, is any of the trigonometric constant coefficients
that are multiplied by the data in the course of the algorithm.

Decimation in frequency

The radix-2 decimation-in-frequency algorithm rearranges the discrete Fourier transform (DFT) equation into
two parts: computation of the even-numbered discrete-frequency indices X(k) for k=[0,2,4,…,N−2] (or X(2r)
and computation of the odd-numbered indices k=[1,3,5,…,N−1] or X(2r+1) )

Regd. No. : Name :

Date :
COLLEGE OF ENGINEERING AND TECHNOLOGY
B.P.U.T., BHUBANESWAR
Department of ELECTRICAL Engineering
Semester 5th Sheet No. aaaaaaa aaaaaaaaaa

Decimation in time

DIT algorithm is used to calculate the DFT of a N-point sequence. The idea is to break the N-point sequence
into two sequences, the DFTs of which can be obtained to give the DFT of the original N-point sequence.

PROGRAM CODE - DIF:

% FFT - Decimation in Frequency


clear all, close all, clc
x1=input('Enter the Input Sequence: '); %input sequence
p=nextpow2(length(x1));
x=[x1 zeros(1,(2^p)-length(x1))];
N=length(x);
S=log2(N);
Half=N/2;
for stage=1:S %defining dif-fft
for index=0:(N/(2^(stage-1))):(N-1)
for n=0:(Half-1)
pos=n+index+1;
pow=(2^(stage-1))*n;

Regd. No. : Name :

Date :
COLLEGE OF ENGINEERING AND TECHNOLOGY
B.P.U.T., BHUBANESWAR
Department of ELECTRICAL Engineering
Semester 5th Sheet No. aaaaaaa aaaaaaaaa

w=exp((-1i)*(2*pi)*pow/N); %twiddle factor


a=x(pos)+x(pos+Half);
b=(x(pos)-x(pos+Half)).*w;
x(pos)=a;
x(pos+Half)=b;
end
end
Half=Half/2;
end
y=bitrevorder(x)
magnitude=abs(y)
phase=angle(y)

%input sequence plot


subplot(3,1,1);
stem(0:length(x)-1,x1,'k','linewidth',1.5);
xlabel('n'); ylabel('x(n)');
title('Input Sequence/Sarthak/358');
%amplitude plot of output
subplot(3,1,2);
stem(0:length(x)-1,abs(y),'k','linewidth',1.5);
xlabel('n'),ylabel('Magnitude');
title('Magnitude response/Sarthak/358');
% phase plot of output
subplot(3,1,3);
stem(0:length(x)-1,angle(y),'k','linewidth',1.5);
xlabel('n'),ylabel('Phase');
title('Phase response/Sarthak/358');

OBSERVATION AND PLOTS:

Fig. 6.1a – Command Window Display of Output Sequence of DIF FFT of the given Sequence

Regd. No. : Name :

Date :
COLLEGE OF ENGINEERING AND TECHNOLOGY
B.P.U.T., BHUBANESWAR
Department of ELECTRICAL Engineering
Semester 5th Sheet No. aaaaaaaa aaaaaaaaa

Fig. 6.1b – Stem Plot of Input Sequence x(n), amplitude and phase plots of DIF FFT Output Sequence

PROGRAM CODE - DIT:

% FFT - Decimation in Time


clear all, close all, clc
x=input('Enter the Input Sequence: '); %input sequence
p=nextpow2(length(x));
x1=[x zeros(1,(2^p)-length(x))];
N=length(x1);
S=log2(N);
Half=1;
x1=bitrevorder(x1);
for stage=1:S % defining dit-fft
for index=0:(2^stage):(N-1)
for n=0:(Half-1)
pos=n+index+1;
pow=(2^(S-stage))*n;
w=exp((-1i)*(2*pi)*pow/N);
a=x1(pos)+x1(pos+Half).*w;
b=x1(pos)-x1(pos+Half).*w;
x1(pos)=a;
x1(pos+Half)=b;
end

Regd. No. : Name :

Date :
COLLEGE OF ENGINEERING AND TECHNOLOGY
B.P.U.T., BHUBANESWAR
Department of ELECTRICAL Engineering
Semester 5th Sheet No. aaaaaaaa aaaaaaaaa

end
Half=2*Half;
end

y=x1
magnitude=abs(y)
phase=angle(y)

%input sequence plot


subplot(3,1,1);
stem(0:length(x)-1,x,'k','linewidth',1.5);
xlabel('n'); ylabel('x(n)');
title('Input sequence/Sarthak/358');
%amplitude plot of output
subplot(3,1,2);
stem(0:length(x)-1,abs(y),'k','linewidth',1.5);
xlabel('n'),ylabel('Magnitude');
title('Magnitude response/Sarthak/358');
% phase plot of output
subplot(3,1,3);
stem(0:length(x)-1,angle(y),'k','linewidth',1.5);
xlabel('n'),ylabel('Phase');
title('Phase response/Sarthak/358');

OBSERVATION AND PLOTS:

Fig. 6.2a – Command Window Display of Output Sequence of DIT FFT of the given Sequence

Regd. No. : Name :

Date :
COLLEGE OF ENGINEERING AND TECHNOLOGY
B.P.U.T., BHUBANESWAR
Department of ELECTRICAL Engineering
Semester 5th Sheet No. aaaaaaaa aaaaaaaaa

Fig. 6.2b – Stem Plot of Input Sequence x(n), amplitude and phase plots of DIT FFT Output Sequence

CONCLUSION:

Hence, in this experiment, for the given input sequence 𝑥(𝑛) = [ 1 , 2 , 0 , 3 ], the output for FFT by DIF
method was found to be 𝑦(𝑘) = [ 6 , 1 + 𝑗 , −4 , 1 − 𝑗 ]. The magnitude and phase of the output sequence
was found to be 𝑦(𝑘) = [6∠𝟎°, 1.4142∠𝟒𝟓°, 0∠𝟏𝟖𝟎°, 1.4142∠ − 𝟒𝟓°]. Also, the FFT of the same
sequence by DIT method was found to be 𝑦(𝑘) = [ 6 , 1 + 𝑗 , −4 , 1 − 𝑗 ]. The magnitude and phase of
the output sequence was found to be 𝑦(𝑘) = [6∠𝟎°, 1.4142∠𝟒𝟓°, 0∠𝟏𝟖𝟎°, 1.4142∠ − 𝟒𝟓°].

Regd. No. : Name :

Date :

Das könnte Ihnen auch gefallen