%Damon Praefke
%Matlab project 3
%25080241

wp=0.4*pi;

ni=[-15:15];
n=[0:30];
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%Ideal lowpass filter h[n]

h=sin(wp.*ni)./(pi.*ni);
h(16)=wp/pi;



%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%Formation of Hamming window

wi1=hamming(31);
wi=wi1';?
hf=h.*wi;

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

figure(1);
stem(n,h); 
title('Plot of h[n]');
xlabel('n');
ylabel('h[n]');

figure(2);
[H,w]=freqz(h,1,256);
freqzplot(H,w); 
title('Plot of frequency response');

figure(3);
[H,f]=fouriert(h,n);
plot(f,abs(H));
title('Fourier Transform of ideal lowpass');
xlabel('f');
ylabel('H');

figure(4);
[Hf,f]=fouriert(hf,n);
plot(f,abs(Hf));
title('Fourier Transform of windowed filter');
xlabel('f');
ylabel('Hf');

figure(5);
stem(n,hf); 
title('Plot of hf[n]');
xlabel('n');
ylabel('hf[n]');
