%Vedrana Sarajlic
%ID#:2730-3757
%EE416
%Project 3: Hamming Window

clear all;
%impulse response Hd
Wp = 0.4*pi;
n = 0:30;
h = sin(Wp*(n-15))./(pi*(n-15));
h(16)=0.4;
%plot in time domain
figure(1);
stem(n,h)

[H,W]= freqz(h,1,256);
%plot in frequency domain 
figure(2);
freqz(h,1)


%FIR filter using Hamming Window
win = hamming(31)
ha = h.*win';
figure(3);
title('Hamming Window')
freqz(ha,1)

%verification
haa = fir1(30,0.4);
Haa = freqz(haa,1,256);
figure(4);
title('Verified design with fir1')
freqz(haa,1)

%Different types of windows are used in spectral analysis and filter design: 
%Hamming, Kaiser, Blackman,Hann, and Dolph-Chebyshew windows.  
%In all cases, the window acts in the time domain by truncating the length of a signal.