BUTTERWORTH LOW PASS FILTER

clc;
clear all;
close all;
format long;
rp=input('Enter Passband Ripple:');
rs=input('Enter Stopband Ripple:');
wp=input('Enter Passband Frequency:');
ws=input('Enter Stopband Frequency:');
fs=input('Enter Sampling Frequency:');
w1=2*wp/fs;
w2=2*ws/fs;
[n,wn]=buttord(w1,w2,rp,rs,'s')
[b,a]=butter(n,wn,'low','s')
w=0:0.1:pi;
[h,om]=freqs(b,a,w);
m=20*log10(abs(h));
an=angle(h);
subplot(2,1,1);
plot(om/pi,m);
ylabel('Gain in dB');
xlabel('(a)Normalized Frequency');
subplot(2,1,2);
plot(om/pi,an);
ylabel('Phase in Radians');
xlabel('(b)Normalized Frequency');

Input:

Enter Passband Ripple:.01
Enter Stopband Ripple:20
Enter Passband Frequency:1000
Enter Stopband Frequency:10000
Enter Sampling Frequency:5000

Output:

No comments:

Post a Comment