Experiment No.10: AIM: - Requirment: - Program
Experiment No.10: AIM: - Requirment: - Program
Experiment No.10: AIM: - Requirment: - Program
10
AIM: - To develop program for designing FIR filter.
REQUIRMENT: - PC having matlab software.
PROGRAM:n=input('enter the length:');
wn=0.5;
wn1=[0.5 0.7];
%for rectangular window
win1=window(@rectwin,n+1);
f1=fir1(n,wn,'low',win1);
[h1 w]=freqz(f1,n);
magh1=20*log(abs(h1));
phaseh1=angle(h1);
subplot(6,4,1);
plot(w/pi,magh1);
subplot(6,4,2);
plot(w/pi,phaseh1);
f2=fir1(n,wn,'high',win1);
[h2 w]=freqz(f2,n);
magh2=20*log(abs(h2));
phaseh2=angle(h2);
subplot(6,4,3);
plot(w/pi,magh2);
subplot(6,4,4);
plot(w/pi,phaseh2);
f3=fir1(n,wn1,'bandpass',win1);
[h3 w]=freqz(f3,n);
magh3=20*log(abs(h3));
phaseh3=angle(h3);
subplot(6,4,5);
plot(w/pi,magh3);
subplot(6,4,6);
plot(w/pi,phaseh3);
f4=fir1(n,wn1,'stop',win1);
[h4 w]=freqz(f4,n);
magh4=20*log(abs(h4));
phaseh4=angle(h4);
subplot(6,4,7);
plot(w/pi,magh4);
subplot(6,4,8);
plot(w/pi,phaseh4);
%for bartlett window
win2=window(@bartlett,n+1);
f5=fir1(n,wn,'low',win2);
[h5 w]=freqz(f5,n);
magh5=20*log(abs(h5));
phaseh5=angle(h5);
subplot(6,4,9);
plot(w/pi,magh5);
subplot(6,4,10);
plot(w/pi,phaseh5);
f6=fir1(n,wn,'high',win2);
[h6 w]=freqz(f6,n);
magh6=20*log(abs(h6));
phaseh6=angle(h6);
subplot(6,4,11);
plot(w/pi,magh6);
subplot(6,4,12);
plot(w/pi,phaseh6);
f7=fir1(n,wn1,'bandpass',win2);
[h7 w]=freqz(f7,n);
magh7=20*log(abs(h7));
phaseh7=angle(h7);
subplot(6,4,13);
plot(w/pi,magh7);
subplot(6,4,14);
plot(w/pi,phaseh7);
f8=fir1(n,wn1,'stop',win2);
[h8 w]=freqz(f8,n);
magh8=20*log(abs(h8));
phaseh8=angle(h8);
subplot(6,4,15);
plot(w/pi,magh8);
subplot(6,4,16);
plot(w/pi,phaseh8);
%for hanning window
win3=window(@hann,n+1);
f9=fir1(n,wn,'low',win3);
[h9 w]=freqz(f9,n);
magh9=20*log(abs(h9));
phaseh9=angle(h9);
subplot(6,4,17);
plot(w/pi,magh9);
subplot(6,4,18);
plot(w/pi,phaseh9);
f10=fir1(n,wn,'high',win3);
[h10 w]=freqz(f10,n);
magh10=20*log(abs(h10));
phaseh10=angle(h10);
subplot(6,4,19);
plot(w/pi,magh10);
subplot(6,4,20);
plot(w/pi,phaseh10);
f11=fir1(n,wn1,'bandpass',win3);
[h11 w]=freqz(f11,n);
magh11=20*log(abs(h11));
phaseh11=angle(h11);
subplot(6,4,21);
plot(w/pi,magh11);
subplot(6,4,22);
plot(w/pi,phaseh11);
f12=fir1(n,wn1,'stop',win3);
[h12 w]=freqz(f12,n);
magh12=20*log(abs(h12));
phaseh12=angle(h12);
subplot(6,4,23);
plot(w/pi,magh12);
subplot(6,4,24);
plot(w/pi,phaseh12);
Figure window:-