clc;
clear all;
close all;
format long;
rp=input('Enter the passband ripple:');
rs=input('Eter the stopband ripple:');
fp=input('Enter the passband frequency:');
fs=input('Enter the stopband frequency:');
f=input('Enter the sampled frequency:');
wp=2*fp/f;
ws=2*fs/f;
num=-20*log10(sqrt(rp*rs));
dem=14.6*(fs-fp)/f;
n=ceil(num/dem);
n1=n+1;
if(rem(n,2)~=0)
n1=n;
n=n-1;
end
y=boxcar(n1);
%Low Pass
b=fir1(n,wp,y);
[h,o]=freqz(b,1,256);
m=20*log10(abs(h));
subplot(221);
plot(o/pi,m);
ylabel('gain in db');
xlabel('(a)normalised frequency');
title('Low Pass');
%High Pass
b=fir1(n,wp,'high',y);
[h,o]=freqz(b,1,256);
m=20*log10(abs(h));
subplot(222);
plot(o/pi,m);
ylabel('gain in db');
xlabel('(b)normalised frequency');
title('High Pass');
%Band Pass
wn=[wp ws];
b=fir1(n,wn,y);
[h,o]=freqz(b,1,256);
m=20*log10(abs(h));
subplot(223);
plot(o/pi,m);
ylabel('gain in db');
xlabel('(c)normalised frequency');
title('Band Pass');
%Band Stop
wn=[wp ws];
b=fir1(n,wn,'stop',y);
[h,o]=freqz(b,1,256);
m=20*log10(abs(h));
subplot(224);
plot(o/pi,m);
ylabel('gain in db');
xlabel('(d)normalised frequency');
title('Band Stop ');
Input:
Enter the Passband Ripple:.01
Enter the Stopband Ripple:.2
Enter the Passband Frequency:1200
Enter the Stopband Frequency:1700
Enter the Sampling Frequency:9000
Output:
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment