Expt - 2 - Frequency Analysis of Signals Using DFT
Expt - 2 - Frequency Analysis of Signals Using DFT
Roll No.
Name:
Aim
To plot magnitude and phase spectrum and perform frequency analysis of
Discrete Time signals
Software/
Online platform Google Colab
used
Theory: The frequency spectrum of an signal is the distribution of the amplitudes and
phases of each frequency component against frequency.
A signal can be converted between the time and frequency domains with a pair
of mathematical operators called a transform. An example is the Fourier
transform, which decomposes a function into the sum of a (potentially infinite)
number of sine wave frequency components. The 'spectrum' of frequency
components is the frequency domain representation of the signal. The inverse
Fourier transform converts the frequency domain function back to a time
function.
Here,
• In DSP, we are able to compute the spectrum only at specific discrete values of
ω,
• Any signal in any DSP application can be measured only in a finite number of
points.
Therefore DFT is suitable tool for frequency analysis , using finite number of
samples of frequency spectrum obtained from DTFT.
Representing the signal into its “N” number of frequency components is N point DFT or
analysis and reconstruction of input sequence from the knowledge of frequency
components is called IDFT or synthesis.
1. To plot N-point DFT magnitude and phase spectrum for different values of N
Code and #To plot N point DFT Magnitude and Phase Spectrum
Output
#Import packages
import numpy as np
from scipy.fftpack import fft
import matplotlib.pyplot as plt
#Input sequence
xn=[1,2,3,4]
#DFT points
N=int(input('How many point DFT:'))
#Compute N point DFT
Xk=fft(xn,N)
print("DFT of x[n]", Xk)
#plot input sequence
plt.stem(xn,use_line_collection=True)
plt.title('Input sequence ')
plt.xlabel('n')
plt.ylabel('x(n)')
plt.show()
Output
Conclusion 1. Through this experiment, we have learned to plot magnitude and phase
spectrum of discrete time sequences.
2. For a discrete sequence of L point, ideally N=L point DFT is required to
compute.
3. For number of DFT points N>L , the frequency spectrum (magnitude and
phase) becomes denser and better represented infrequency domain.
Test your
understanding
1. What is meaning of spectrum of a signal?
2. Which mathematical tool (transform) is required to get frequency spectrum?
3. For a L-point sequence , minimum how many DFT points needed , for proper
reconstruction of original sequence?
4. Why in practice, number of DFT points much greater actual length of
sequence?
5. What is the result on reconstructed sequence (using N-point IDFT ), where
length of original sequence is L point (and N>L)?