Experiment 10
Experiment 10
Aim: Design a Butterworth low pass analog filter to satisfy the following
requirements pass-band cutoff=40Hz, stop-band cutoff=150Hz, pass-band ripple
Rp=1dB and stop-band ripple Rs=60dB. Plot the magnitude and phase frequency
response of the filter
Apparatus:
MATLAB Software
Theory:
Cutoff Frequency (ωc): This is the frequency at which the output power drops
to half its maximum value (or -3 dB point). Frequencies below this value are
allowed to pass with minimal attenuation.
Filter Order (n): The order of the filter determines the steepness of the roll-off
beyond the cutoff frequency. A higher order results in a sharper transition from
the pass-band to the stop-band, enhancing attenuation of unwanted high
frequencies.
Stop-band Ripple (Rs): This indicates the allowable ripple in the stop-band.
For Butterworth filters, while there is no ripple in the pass-band, the stop-band
is defined by the level of attenuation.
Filter Design
1. Determine the Filter Order (n): The required order can be calculated using
the formula:
This formula ensures that the filter meets the specified stop-band and pass-
band requirements.
2. Cutoff Frequency (ωc): The cutoff frequency is typically set to the pass-
band cutoff frequency.
3. Transfer Function: The transfer function of an n-order Butterworth filter is
given by:
This function describes how the filter modifies the input signal.
CODE:
fs=1000;
wp=40;
ws=150;
Rp=1;
Rs=60;
w1= 2*wp/fs;
w2= 2*ws/fs;
[N,wn]=buttord(w1,w2,Rp,Rs);
display(N);
[b,a]=butter(N,wn,'low');
[h,w]=freqz(b,a,128,1000);
plot(w/pi,abs(h));
display(wn);
title('Butterworth HPF(N=original(6)');
xlabel('Normalised frequency');
ylabel('Amplitude;');
grid on;
axis([0 120 0 1.2]);
FOR DIFFERENT N:
clc;
clear all;
close all;
wp=40/1000;
ws=150/1000;
rp=1;
rs=60;
[N,wn]=buttord(wp,ws,rp,rs);
n=2;
[b1,a1]=butter(n,wn,'low');
[h1,w1]=freqz(b1,a1,128,1000);
n=4;
[b2,a2]=butter(n,wn,'low');
[h2,w2]=freqz(b2,a2,128,1000);
n=6;
[b3,a3]=butter(n,wn,'low');
[h3,w3]=freqz(b3,a3,128,1000);
n=8;
[b4,a4]=butter(n,wn,'low');
[h4,w4]=freqz(b4,a4,128,1000);
n=10;
[b5,a5]=butter(n,wn,'low');
[h5,w5]=freqz(b5,a5,128,1000);
plot(w1/pi,abs(h1),w2/pi,abs(h2),w3/pi,abs(h3),w4/pi,abs(h4),w5/pi,abs(h5));
legend('N=2','N=4','N=6','N=8','N=10');
title('Butterworth LPF');
xlabel('Normalised frequency');
ylabel('Amplitude');
grid on;
axis([0 50 0 1.2]);
2)HIGH PASS:
clc;
clear all;
close all;
fs=1000;
wp=40;
ws=150;
Rp=1;
Rs=60;
w1= 2*wp/fs;
w2= 2*ws/fs;
[N,wn]=buttord(w1,w2,Rp,Rs);
display(N);
[b,a]=butter(N,wn,'high');
[h,w]=freqz(b,a,128,1000);
plot(w/pi,abs(h));
display(wn);
title('Butterworth HPF(N=original(6)');
xlabel('Normalised frequency');
ylabel('Amplitude;');
grid on;
axis([0 120 0 1.2]);
FOR DIFFERENT N:
clc;
clear all;
close all;
wp=40/1000;
ws=150/1000;
rp=1;
rs=60;
[N,wn]=buttord(wp,ws,rp,rs);
n=2;
[b1,a1]=butter(n,wn,'low');
[h1,w1]=freqz(b1,a1,128,1000);
n=4;
[b2,a2]=butter(n,wn,'low');
[h2,w2]=freqz(b2,a2,128,1000);
n=6;
[b3,a3]=butter(n,wn,'low');
[h3,w3]=freqz(b3,a3,128,1000);
n=8;
[b4,a4]=butter(n,wn,'low');
[h4,w4]=freqz(b4,a4,128,1000);
n=10;
[b5,a5]=butter(n,wn,'low');
[h5,w5]=freqz(b5,a5,128,1000);
plot(w1/pi,abs(h1),w2/pi,abs(h2),w3/pi,abs(h3),w4/pi,abs(h4),w5/pi,abs(h5));
legend('N=2','N=4','N=6','N=8','N=10');
title('Butterworth LPF');
xlabel('Normalised frequency');
ylabel('Amplitude');
grid on;
axis([0 50 0 1.2]);
Output graphs:
1)Low Pass
2)High Pass
i) N=6; ii) N={2,4,6,8,10};
Conclusion:
In this experiment we learned how to design butterworth low pass filter and high
pass filter for given passband cutoff frequency and stopband cutoff frequency also
learned to plot the magnitude and phase response of the filters