Skip to content

Instantly share code, notes, and snippets.

@Arunprakash-A
Last active August 27, 2018 17:06
Show Gist options
  • Save Arunprakash-A/5e133beed21800249622aeb02b8ff377 to your computer and use it in GitHub Desktop.
Save Arunprakash-A/5e133beed21800249622aeb02b8ff377 to your computer and use it in GitHub Desktop.
%**********************Designing of LP FIR Filter*************************%
%************Author : Arun Prakash A *******************************%
clc;
close all;
clear all;
n=7; % Order of the filter : change it to 71 and see what happens
w=0.5;
h_n=fir1(n,w);
[H,W]=freqz(h_n,1);
% window(:,1)=H;
subplot(414)
plot(W,abs(H));
set(gca,'XTick',0:pi/2:pi)
set(gca,'XTickLabel',{'0','\pi/2','\pi'})
xlabel('\omega')
ylabel('H(e^j^w)')
title('Using Hamming Window');
h_n=fir1(n,w,hann(n+1)');
[H,W]=freqz(h_n,1);
% window(:,2)=H;
subplot(412)
plot(W,abs(H));
set(gca,'XTick',0:pi/2:pi)
set(gca,'XTickLabel',{'0','\pi/2','\pi'})
xlabel('\omega')
ylabel('H(e^j^w)')
title('Using Hanning Window');
h_n=fir1(n,w,blackman(n+1));
[H,W]=freqz(h_n,1);
% window(:,3)=H;
subplot(413)
plot(W,abs(H));
set(gca,'XTick',0:pi/2:pi)
set(gca,'XTickLabel',{'0','\pi/2','\pi'})
xlabel('\omega')
ylabel('H(e^j^w)')
title('Using BlackMan Window');
h_n=fir1(n,w,ones(1,n+1)');
[H,W]=freqz(h_n,1);
% window(:,4)=H;
subplot(411)
plot(W,abs(H));
set(gca,'XTick',0:pi/2:pi)
set(gca,'XTickLabel',{'0','\pi/2','\pi'})
xlabel('\omega')
ylabel('H(e^j^w)')
title('Using Rectangular Window');
% figure
% plot(W,abs(window))
% legend('Hamming','Hanning','Blackman','Rectangular')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment