%MAHAM N  DARD
%2839-5948
%PROJECT 3
%DIGITAL SIGNAL PROCESSING
%DUE:NOV 13

%hd(n)=sin(Wp*n)/pi*n, 
%values of n,n=-3,-2,-1,0,1,2,3...
%cutoff frequency wp=.4*pi


clear all;


wp=0.4*pi;                    %already provided cut of frequency
a1=0:30;
h=sin(wp*(a1-15))./(pi*(a1-15));
h(16)=wp/pi;

[H,W] = freqz(h,1,256);       %taking frequency response of signal
mag=20*log10(abs(H));
figure(1);
plot(a1,h);                 %function is plotted here by command plot
title('IMPULSE RESPONSE');  %assigns title to the plot
xlabel('time');
ylabel('impulse response');

%________________________________________________________________________________

figure(2);
plot(W/pi,mag);             %plots the function of w/pi against mag
title('magnitude plot');    %assigns title to the plot
xlabel('time');
ylabel('H(ejw')

%_________________________________________________________________________________

% part2

%here we have to design an FIR filter by the use of hamming window
%hf(n)=h(n)*w(n)
%w(n)=hamming window

length(h);
windo=(hamming31);
length=(windo);
h1=h*(windo);
[H1,W1]=freqz(h1,1,256);
mag=20*log10(abs(H1));
figure(3);
plot(a1,h1);                %plots a1 against h1
xlabel('time');             %assigns x label on the plot for graph 
ylabel('');

%___________________________________________________________________________________

%part3

%3b) 3 types of window and applications used

%3c)kaiser,hamming,gaussian

%3d)uses hamming window as used in this project with N+1 length

%3a)different types of window and application