Download as pdf or txt
Download as pdf or txt
You are on page 1of 5

Department of electronics engeenring...........................................................................................

1
FIR filter design.............................................................................................................................. 1
order ccalculation .......................................................................................................................... 1
window selection........................................................................................................................... 2
frequency response ....................................................................................................................... 2
frequency response ....................................................................................................................... 2
hanning window ............................................................................................................................ 3
frequency response ....................................................................................................................... 3
blackman window.......................................................................................................................... 4
frequency response ....................................................................................................................... 4
Department of electronics engeenring
yeshwantrao chawan collage of engeenering

%name of student = CHETAN SETIYA


%roll no. = 143
%section = B
%batch = B3
%date = 11/11/22

FIR filter design


clc;
clear all;
close all;
% rp=input('enter passband ripple');
% rs=input ('enter the stopband ripple');
% wp=input('enter passband freq');
% ws=input ('enter stopband freq');
% fs=input('enter sampling freq');
rp=0.1; % passband ripple
rs=0.1 ;%stopband ripple
wp=0.6; %passband freq
ws=0.9;%stopband freq
fs=2000; %sampling freq

%m\normalise frequency
w1=2*wp/fs;
w2=2*ws/fs;

order ccalculation
num=-20*log10(sqrt(rp*rs))-13;
dem=14.6*(ws-wp)/fs;
n=ceil(num/dem);
n1=n+1;
if(rem(n,2)~=0)
n1=n; n=n-1;
end
window selection
y=rectwin(n1);
disp("rectangular window filter response ");

rectangular window filter response

frequency response
b=fir1(n,w1,y);
[h,o]=freqz(b,1,256);
%magnitude and phase plot
m=20*log10(abs(h));
figure
plot(o/pi,m );
title('LPF of rectangular');
xlabel('normalized freqency -->');
ylabel('gain in db-->');

y=hamming(n1);
disp("hamming window filter response");

hamming window filter response

frequency response
b=fir1(n,w1,y);
[h,o]=freqz(b,1,256);
%magnitude and phase plot
m=20*log10(abs(h));
figure
plot(o/pi,m );
title('LPF of hamming');
xlabel('normalized freqency -->');
ylabel('gain in db-->');

hanning window
y=hann(n1);
disp("hann window filter response");

hann window filter response

frequency response
b=fir1(n,w1,y);
[h,o]=freqz(b,1,256);
%magnitude and phase plot
m=20*log10(abs(h));
figure
plot(o/pi,m );
title('LPF of hann');
xlabel('normalized freqency -->');
ylabel('gain in db-->');
blackman window
y=blackman(n1);
disp("blackman window filter response");

blackman window filter response

frequency response
b=fir1(n,w1,y);
[h,o]=freqz(b,1,256);
%magnitude and phase plot
m=20*log10(abs(h));
figure
plot(o/pi,m );
title('LPF of blackman');
xlabel('normalized freqency -->');
ylabel('gain in db-->');
Published with MATLAB® R2022a

You might also like