%Amine Fardidi (29061780)
%Project #3
%============================================================================================
% 1-
%============================================================================================
Wp=0.4*pi;
n=0:1:30;
h=sin(wp*(n-15))./(pi*(n-15));
h(16)=wp/pi;

figure (1)
plot(n,h);
title('Impulse response');

[H, W]= freqz(h,1,512);
mag=20*log10(abs(H));

figure (2)
plot(W/pi, mag);
title('Frequency response');
xlabel('freq from 0 to 1');
ylabel('H');

%============================================================================================
% 2-
%============================================================================================

l= length(h);
win=hamming(l);
h1=h.*win';

figure (3)
plot(n, h1);
title('Impulse response');

[H1, W1]=freqz(h1,1,512);
mag1=20*log10(abs(H1));

figure (4)
plot(W1/pi, mag1);
title('Frequency response H1');
xlabel('freq from 0 to 1');
ylabel('H1');

%===========================================================================================
% 3-
%===========================================================================================
%