You are on page 1of 5

KINZA PERVEZ

EE-20141
LAB SESSION 9

Object of this lab is introduction to digital filters and its types, design FIR filter and study how it
performs filtering on a signal. Further truncate different types of FIR filter like Low Pass, High
Pass, Band Pass using different windows like rectangular, Kaiser Etc. and compare the results
obtained from different windows.

TASK#1:

TASK#2:
Cycles present will be integral multiple of ΔF till Fs/2 after which alias frequency would start to
be plotted and since 440 is not an integral multiple of ΔF this would lead to spectral leakage in
frequency plot.
TASK#3:
clear all; close all; clc;

F1 = 500; F2 = 600;
Fs = 8000; Ts = 1/Fs;
N = 64; n =[0:N-1];
k = n;
Df = Fs/N;
Fk = k.*Df;
x1 = sin(2*pi*F1*n*Ts);
X1 = abs(fft(x1,N));
x2 = sin(2*pi*F2*n*Ts);
X2 = abs(fft(x2,N));

subplot(4,1,1)
plot(n*Ts,x1,'r'); hold;
stem(n*Ts,x1,'filled')
xlabel('Time (sec)'); ylabel('Amplitude');
title('Signal'); grid; axis tight

subplot(4,1,2)
stem(Fk,X1,'r','filled')
xlabel('Frequency (Hz)'); ylabel('DFT Magnitude')
title('Spectrum'); xlim([0 Fs]);grid;
KINZA PERVEZ
EE-20141
LAB SESSION 9

subplot(4,1,3)
plot(n*Ts,x2,'r'); hold
stem(n*Ts,x2,'filled')
xlabel('Time (sec)'); ylabel('Amplitude');
title('Signal'); grid; axis tight;

subplot(4,1,4)
stem(Fk,X2,'r','filled')
xlabel('Frequency (Hz)'); ylabel('DFT Magnitude');
title('Spectrum'); xlim([0 Fs]); grid;

TASK#4:

TASK#5:
clear all;close all;clc;

F = 1050; 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+pi/4);
w = window(@triang,N);
xw = x.*w'; % Windowed signal
X = abs(fft(x));
KINZA PERVEZ
EE-20141
LAB SESSION 9

Xw = abs(fft(xw));

subplot(321)
plot(n*Ts,x,'g');hold
stem(n*Ts,x,'filled','k')
xlabel('Time (sec)');ylabel('Amplitude')
title('Signal');grid

subplot(322)
stem(Fk,X,'filled','k')
xlabel('Frequency (Hz)');ylabel('DFT Magnitude')
title('Spectrum');grid

subplot(323)
stem(n,w,'g','filled')
xlabel('Samples');ylabel('Amplitude')
title('Window Function');grid;axis tight

subplot(324)
stem(abs(fft(w)),'k','filled')
xlabel('Samples');ylabel('Magnitude')
title('Spectrum of Window Function');grid;axis tight

subplot(325)
plot(n*Ts,xw,'g');hold
stem(n*Ts,xw,'filled','k')
xlabel('Time (sec)');ylabel('Amplitude')
title('Windowed Signal');grid;axis tight

subplot(326)
stem(Fk,Xw,'filled','k')
xlabel('Frequency (Hz)');ylabel('Windowed DFT Magnitude')
title('Windowed Spectrum');grid

Triangular Window
KINZA PERVEZ
EE-20141
LAB SESSION 9

Hamming Window

Hanning Window

Blackman Window
KINZA PERVEZ
EE-20141
LAB SESSION 9

FlatTop Window

Gaussian Window

You might also like