Matlab Program for Rectangular Window Technique

clc;
clear all;
close all;
rp=0.05;
rs=0.04;
fp=1500;
fs=2000;
f=9000;
wp=(2*fp)/f
ws=(2*fs)/f
num=(-20*log10(sqrt(rs*rp)))-13;
den=(14.6)*(fs-fp)/fs;
n=ceil(num/den)
n1=n+1;
if(rem(n,2)~=0)
  n1=n;
  n=n-1;
end;
y=boxcar(n1);
b=(fir1(n,wp,y));
[h,w]=freqz(b,1,256);
subplot(2,2,1)
plot(w/pi,angle(h));
xlabel('freq in hz');
ylabel('freq in db');
title('phase response of 1st order lpf' );
subplot(2,2,2)
plot(w/pi,20*log10(abs(h)));
xlabel('freq in hz');
ylabel('freq in db');
title('phase response of 1st order lpf' );
c=fir1(n,wp,'high',y);
[h,w]=freqz(c,1,256);
subplot(2,2,3)
plot(w/pi,angle(h));
xlabel('freq in hz');
ylabel('radians');
title('phase response of 1st order hpf' );
subplot(2,2,4)
plot(w/pi,20*log10(abs(h)));
xlabel('freq in hz');
ylabel('freq in db');
title('phase response of 1st order hpf' );
figure(2);
wn=[wp,ws];
c=fir1(n,wn,'bandpass',y);
[h,w]=freqz(c,1,256);

subplot(2,2,1)
plot(w/pi,angle(h));
xlabel('freq in hz');
ylabel('radians');
title('phase response of 1st order bpf' );
subplot(2,2,2)
plot(w/pi,20*log10(abs(h)));
xlabel('freq in hz');
ylabel('freq in db');
title('phase response of 1st order bpf' );
c=fir1(n,wp,'stop',y);
[h,w]=freqz(c,1,256);
subplot(2,2,3)
plot(w/pi,angle(h));
xlabel('freq in hz');
ylabel('radians');
title('phase response of 1st order bsf' );


subplot(2,2,4)
plot(w/pi,20*log10(abs(h)));
xlabel('freq in hz');
ylabel('freq in db');
title('phase response of 1st order bsf' );








About the author

Rajnesh
Student of Swarnandhra Engineering College Pursuing B.Tech final year in the Stream of ECE...

0 comments:

Template by Rajnesh
Copyright © 2012 SWEC COMMUNICS and Blogger Themes.