Pages

Thursday, 25 April 2013

Butterworth Analog Band Pass Filter Using Function (Matlab 2012a)

Program:

clc;
clear all;
rp = input('Enter the passband ripple = ');
rs = input('Enter the stopband ripple = ');
wp = input('Enter the passband frequency = ');
ws = input('Enter the stopband frequency = ');
fs = input('Enter the sampling frequency = ');
w1 = 2*wp/fs;
w2 = 2*ws/fs;
[n] = buttord(w1,w2,rp,rs);
wn = [w1 w2];
[b,a] = butter(n,wn,'bandpass','s');
w = 0:.01: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('Normalised Frequency ---->');
title('Magnitude Response');
grid on;
subplot(2,1,2);
plot(om/pi,an);
xlabel('Normalised Frequency ---->');
ylabel('Phase in Radians ---->');
title('Phase Response');
grid on;


Output:

Enter the passband ripple = 0.36
Enter the stopband ripple = 36
Enter the passband frequency = 1500
Enter the stopband frequency = 2000
Enter the sampling frequency = 6000


Waveform:

 

No comments:

Post a Comment