Pages

Monday 22 April 2013

Butterworth Analog Low 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,wn] = buttord(w1,w2,rp,rs,'s');
[z,p,k] = butter(n,wn);
[b,a] = zp2tf(z,p,k);
[b,a] = butter(n,wn,'s');
w = 0: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);
title('Amplitude Response');
ylabel('Gain in dB ---->');
xlabel('Normalised frequency ---->');
grid on;
subplot(2,1,2);
plot(om/pi,an);
title('Phase Response');
xlabel('Normalised frequency ---->');
ylabel('Phase in radians ---->');
grid on;


Output:

Enter the passband ripple = 0.15
Enter the stopband ripple = 60
Enter the passband frequency = 1500
Enter the stopband frequency = 3000
Enter the sampling frequency = 7000


Waveform:

 

2 comments:

  1. This comment has been removed by the author.

    ReplyDelete
  2. Why is sampling frequency required in designing an analog LPF? I don't understand why do you do w1=2*wp/fs??

    ReplyDelete