clear all;
wp=0.2*pi; ws=0.3*pi;
tr_width=ws-wp;
M=ceil(6.6*pi/tr_width)+1;
n=0:1:M-1;
wc=(ws+wp)/2;
hd=ideal_lp(wc,M);
w_ham=(hammingwin(M));
h=hd.*w_ham;
[db,mag,w]=freqz_k(h,[1]);
%delta_w=2*pi/1000;
%Rp=-(min(db(1:1:wp/delta_w+1)));
%As=-round(max(db(ws/delta_w+1:1:501)));
subplot(221)
stem(n,hd),title('Ideal Low Pass Impulse Response');grid
axis([0 M-1 -0.1 0.3]),xlabel('n'),ylabel('hd(n)');
subplot(222)
stem(n,w_ham),title('Hamming Window');grid
axis([0 M-1 0 1.1]),xlabel('n'),ylabel('w(n)');
subplot(223)
stem(n,h),title('Actual Impulse Response (Ideal_lp h(n) * Hamming Window)');grid
axis([0 M-1 -0.1 0.3]),xlabel('n'),ylabel('h(n)');
subplot(224)
plot(w/pi,mag),title('Magnitude Response in db');grid
axis([0 .6 -.1 1.1]),xlabel('Frequency in PI'),ylabel('Desibels');