Você está na página 1de 4

Lab Session 08

BE (EL)

Digital Signal Processing

DFT Leakage and Windowing


OBJECTIVE: The purpose of this lab is to become familiar with the practical constraints in calculating the
Fourier transform of any real world signal.
Part-A
1. Generate a sinusoid of frequency 1000 Hz which should be sampled at 8000 samples/sec.
2. Take 64 point DFT of the generated signal and observe the spectrum.
3. Comment on the DFT Leakage phenomenon for the above case.
Part-B
1.
2.
3.
4.
5.
6.

Now generate a sinusoid of frequency 1100 Hz sampled at 8000 samples/sec.


Take 64 point DFT of the generated signal and observe the spectrum.
Comment on the DFT Leakage phenomenon for the above case.
Generate a suitable window function of 64 points.
Apply windowing to the signal and observe the spectrum of windowed signal.
Now take 128, 256 and 512 point DFTs for the above generated signal and observe the Leakage
phenomenon.

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
]

Note: summation means finding area in discrete as in integration in continuous.


Taking an 8 point DFT of an input sequence means multiplying the input sequence with cosine and sine
of 0, 1, 2, 3, 4, 5, 6, 7 cycles / sample interval (N) where N indicates length of DFT.

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)

Digital Signal Processing

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)

Digital Signal Processing

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)

Digital Signal Processing

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.

Você também pode gostar