Escolar Documentos
Profissional Documentos
Cultura Documentos
BE (EL)
THEORY:
DFT works by the same principle of Fourier Series: When you need to detect whether a particular sine
wave or cosine wave of a certain frequency is in the input signal, you have to multiply the input signal
with that particular sine or cosine wave and find the area. If the input signal contains that frequency, it
will show up as non-zero area and all other frequency components (of frequencies which are integer
multiple of fundamental frequency) will have zero area.
DFT equation:
1
() = ()[
1
=0
() = ()[cos
=0
2
2
sin
]
If the input signal contains frequency which is integer multiple of analysis frequencies (k*Fs/N),
it will show up only at the correct DFT output bin or frequency. All other DFT output bins will be
zero. It means spectrum is correctly estimated/calculated and no DFT leakage occurs in this
Lab Session 08
BE (EL)
case. But this is an ideal case to dictate the ingredient components of real world signal to
become integral multiple of analysis frequencies.
If the input signal contains frequency which is NOT integer multiple of analysis frequencies
(which is the most probably happening case), it will show up in all DFT output bins. This effect is
simply known as DFT Leakage/ Spectral Leakage. We typically say that input signal energy
shows up in all of the DFT's output bins or the DFT magnitude will spread in the whole spectrum.
Note: Another way to think about DFT leakage is, when the input signal has frequencies which do not
complete integer number of cycles in the sample interval N, the input to DFT seems like abruptly
starting and abruptly ending giving rise to side lobes in the DFT output.
PROCEDURE:
1. Make a folder at desktop and name it as your current directory within MATLAB.
2. Open M-file editor and write the code:
Part-A
clear all;close all;clc;
F = 1000;
Fs = 8000;
Ts = 1/Fs;
N = 64;
n =[0:N-1];
k = n;
Df = Fs/N;
Fk = k.*Df;
x = sin(2*pi*F*n*Ts);
X = abs(fft(x));
subplot(211)
stem(n*Ts,x,'filled')
xlabel('Time(sec)')
ylabel('Amplitude')
title('Signal')
axis tight
subplot(212)
stem(Fk,X,'filled')
xlabel('Frequency (Hz)')
ylabel('DFT Magnitude')
title('Spectrum')
axis tight
3. Save the file as P081.m in your current directory and run it.
Lab Session 08
BE (EL)
Part-B
clear all; close all; clc;
F = 1100;
Fs = 8000;
Ts = 1/Fs;
N = 64;
n =[0:N-1];
k = n;
Df = Fs/N;
Fk = k.*Df;
x = sin(2*pi*F*n*Ts);
w = window(@hamming,N);
xw = x.*w';
X = abs(fft(x));
Xw = abs(fft(xw));
subplot(321)
stem(n*Ts,x,'filled')
xlabel('Time(sec)')
ylabel('Amplitude')
title('Signal')
axis tight
subplot(322)
stem(Fk,X,'filled')
xlabel('Frequency (Hz)')
ylabel('DFT Magnitude')
title('Spectrum')
axis tight
subplot(323)
stem(n,w,'r','filled')
xlabel('Samples')
ylabel('Amplitude')
title('Window Function')
axis tight
subplot(325)
stem(n*Ts,xw,'filled')
xlabel('Time(sec)')
ylabel('Amplitude')
title('Windowed Signal')
axis tight
subplot(326)
stem(Fk,Xw,'filled')
xlabel('Frequency (Hz)')
ylabel('Windowed DFT Magnitude')
title('Windowed Spectrum')
axis tight
4. Save the file as P082.m in your current directory and run it.
5. Explore and take notes.
EXERCISE/TASK:
Task-1
Using wintool(Window Design & Analysis Tool) in command window; Attach the time domain and
frequency domain representations of various window functions like Rectangular (no window),
Triangular, Hamming, Hanning, Blackman etc and make a comparison between their performance on the
basis of following attributes:
a) width of the main lobe
b) the first (highest)side lobe magnitude in dB
c) the rate of side lobes falloff
Lab Session 08
BE (EL)
Task-2
Develop a MATLAB code to perform an 8-point DFT on a continuous input signal containing components
at 1 kHz and 2 kHz, expressed as () = sin(21000) + 0.5 sin(22000 + 3/4). Taking sampling
rate = 8000 samples/sec. Will there any DFT Leakage happen?
Task-3
Develop a MATLAB code to perform an 8-point DFT on a continuous input signal containing components
at 1 kHz and 2 kHz, expressed as () = sin(21333) + 0.5 sin(22000 + 3/4). Taking sampling
rate = 8000 samples/sec. Will there any DFT Leakage happen? If yes, then apply windowing to reduce
the effect. Choose different window functions of your own interest.