Professional Documents
Culture Documents
% Designing of LPF Using Hamming Window % Take Cut Off Frequency WP As Input % H (N) Sin (WP (N-T) ) /pi (N-T) When N ! T % H (N) Wp/pi When N T
% Designing of LPF Using Hamming Window % Take Cut Off Frequency WP As Input % H (N) Sin (WP (N-T) ) /pi (N-T) When N ! T % H (N) Wp/pi When N T
clc;
clf;
close all;
if k==1
w=ones(1,N);
figure(2);
stem(n,w);
xlabel('sampel number');
ylabel('Amplitude');
title('Rectangular Window');
elseif k==2
w=0.5-0.5*cos(2*pi*n/(N-1));
figure(2);
stem(n,w);
xlabel('sampel number');
ylabel('Amplitude');
title('Hanning Window');
elseif k==3
w = 0.54-0.46*(cos(2*pi*n/(N-1)));
figure(2);
stem(n,w);
xlabel('sampel number');
ylabel('Amplitude');
title('Hamming Window');
elseif k==4
w=0.42-0.5*cos(2*pi*n/(N-1))+0.08*cos(4*pi*n/(N-1));
figure(2);
stem(n,w);
xlabel('sampel number');
ylabel('Amplitude');
title('Blackman Window');
else disp('the number you have entered in not in the range');
end
y=h.*w;
figure(3);
stem(n,y);
title('impulse response of filter h(n)*w(n)');
xlabel('sampel number');
ylabel('Amplitude');
z=fftshift(abs(fft(y)));
f=-4000:(8000/1024):4000;
figure(4)
plot(f,z);
xlabel('frequency in hertz');
ylabel('Amplitude Spectrum');
title('Amplitude spectrum of FIR LPF');
end