Untitled document (8)
Untitled document (8)
Ex.No -4
Frequency Analysis using Discrete Fourier Transform
Date:
AIM:
To generate DFT for the given sequence using MATLAB program.
APPARATUS REQUIRED:
MATLAB , PC
THEORY:
The discrete Fourier transform [DFT] is a powerful computation tool which allow us
to evaluate the Fourier transform X(ejω) on a digital computer (or) specially designed
hardware .unlike DTFT, which is defined for finite of infinite sequences ,DFT is defined only
for sequence of finite of infinite length. since X(ejω) is continues and periodic , DFT is
obtained by sampling one period of the Fourier transform at a finite no of frequency points
.DFT plays an important role in the implementation of many signal processing algorithms.
Apart from determining the frequency content of a signal .DFT performs linear filtering in
frequency domain. Discrete Fourier transform [DFT] is given by, X(k)=∑x(n) e-j2πkn/N where
n and k varies 0,1,2…N-1.the inverse DFT is given by
x(n) = (1/N) ∑X (k) ej2πkn/N where n and k varies 0,1,2…N-1.
ALGORITHM:
1. DIRECT COMPUTATION METHOD:
● Read the input sequence and compute its length.
● Compute the imaginary and real part of the sequence.
● Plot the magnitude and phase response of the DFT sequence.
2. FFT ALGORITHM:
● Represent the given discrete sequence in the vector form.
● Define the length of required DFT.
● Incorporate the condition N = L.
● If the condition is true compute DFT by using suitable MATLAB command.
● If N < L , display the error message.
● IfN > L, pad extra zeros to the original discrete sequence asrequired and then
computethe DFT using suitable MATLAB command.
● Display the magnitude and phase values of the DFT sequence.
● Plot a stem graph between indices of N and absolute values.
● Plot a stem graph between indices of N and angle values.
3. IDFT ALGORITHM:
● Represent the given discrete sequence in the vector form.
● Define the length of required IDFT.
● Incorporate the condition N = L.
● If the condition is true compute IDFT by using suitable MATLABcommand.
● If N < L , display the error megasege.
LOYOLA - ICAM
COLLEGE OF ENGINEERING AND TECHNOLOGY (LICET)
● IfN > L, pad extra zeros to the original discrete sequence as required and
Thencompute the IDFT using suitable MATLABcommand.
● Display the magnitude and phase values of the IDFT sequence.
● Plot a stem graph between indices of N and absolute values.
● Plot a stem graph between indices of N and angle values.
PROGRAM:
1.FFT:
a = input('Enter The sequence: ');
n = input('Enter the number of points for FFT: ');
n1 = length(a);
if n == n1
X = fft(a, n);
elseif n1 < n
a = [a, zeros(1, n - n1)];
X = fft(a, n);
else
disp('Error in input');
end
disp(X);
magnitudeX = abs(X);
subplot(2,1,1);
stem(0:n-1,a);
title('Input');
xlabel('Index');
ylabel('Magnitude');
subplot(2,1,2);
stem(0:n-1, magnitudeX);
title('FFT');
xlabel('Index');
ylabel('Magnitude');
OUTPUT:
Enter The sequence: [1 1 2 2 3 3 4 4]
Enter the number of points for FFT: 8
Columns 1 through 5
Columns 6 through 8
2. IFFT:
OUTPUT:
Enter The sequence: [20.0000 + 0.0000i -2.0000 + 4.8284i -2.0000 + 2.0000i -2.0000 +
0.8284i 0.0000 + 0.0000i -2.0000 - 0.8284i -2.0000 - 2.0000i -2.0000 - 4.8284i]
3. FFT USING FORMULA
OUTPUT:
Enter the sequence: [1 1 2 2 3 3 4 4]
FFT result:
20.0000 + 0.0000i
-2.0000 + 4.8284i
-2.0000 + 2.0000i
-2.0000 + 0.8284i
0.0000 - 0.0000i
-2.0000 - 0.8284i
-2.0000 - 2.0000i
-2.0000 - 4.8284i
LOYOLA - ICAM
COLLEGE OF ENGINEERING AND TECHNOLOGY (LICET)
GRAPH:
OUTPUT:
Enter the sequence: [1 1 1 1 1 1 1 1]
IFFT result:
1.0000 + 0.0000i
-0.0000 - 0.0000i
-0.0000 + 0.0000i
-0.0000 - 0.0000i
0.0000 + 0.0000i
-0.0000 + 0.0000i
-0.0000 + 0.0000i
0.0000 - 0.0000i
LOYOLA - ICAM
COLLEGE OF ENGINEERING AND TECHNOLOGY (LICET)
GPRAH:
Preparation 5
Conduction &
Observation 5
Result Execution
Viva-Voce &
5
Inference
Record 5
Total 20
RESULT:
Thus the DFT and IDFT of the given discrete sequence and the magnitude and phase
response was plotted.