Analog Filters
Analog Filters
http://vlabs.iitkgp.ernet.in/dsp/exp8/index.html#
Algorithm
Parameters Description
Wp Passband corner frequency
Ws Stopband corner frequency
Rp Passband ripple, in decibels
Rs Stopband attenuation, in decibels
n the lowest order the proposed Butterworth filter
Wn corresponding cut-off frequency
2. butter
Syntax
[b,a] = butter(n,Wn)
[b,a] = butter(n,Wn,'ftype’)
[b,a] = butter(n,Wn,'s’)
Description
Designs lowpass, bandpass, highpass, and bandstop digital and analog Butterworth filters. Butterworth filters
are characterized by a magnitude response that is maximally flat in the passband and monotonic overall.
1. Program for the design of Butterworth analog low pass filter
clc; clear all; close all;
format long;
wp=input('Please enter the first pass band frequency (Hz): ');
ws=input('Please enter the first stop band frequency (Hz): ');
rp=input('Please enter the pass band ripple: ');
rs=input('Please enter the stop band ripple: ');
fs=input('Please enter the sampling frequency: (Hz)');
w1=2*wp/fs;
w2=2*ws/fs;
[n,wn]=buttord(w1,w2,rp,rs);
[b,a]=butter(n,wn)
w=0:0.01:pi;
[h,om]=freqz(b,a,w);
m=20*log10(abs(h));
an=angle(h);
subplot(2,1,1); plot(om/pi,m);
ylim([-300 50]);
ylabel('gain in dB');
xlabel('Normalised frequency');
subplot(2,1,2);plot(om/pi,an);
ylabel('Phase in Radian');
xlabel('Normalised frequency');
Frequency response of the designed filter
2. Program for the design of Butterworth High pass filter
clc; clear all; close all;
format long;
wp=input('Please enter the first pass band frequency (Hz): ');
ws=input('Please enter the first stop band frequency (Hz): ');
rp=input('Please enter the pass band ripple: ');
rs=input('Please enter the stop band ripple: ');
fs=input('Please enter the sampling frequency: (Hz)');
w1=2*wp/fs;
w2=2*ws/fs;
[n,wn]=buttord(w1,w2,rp,rs);
[b,a]=butter(n,wn,'high');
w=0:0.01:pi;
[h,om]=freqz(b,a,w);
m=20*log10(abs(h));
an=angle(h);
subplot(2,1,1); plot(om/pi,m);
ylim([-300 50]);
ylabel('gain in dB');
xlabel('Normalised frequency');
subplot(2,1,2);plot(om/pi,an); ylabel('Phase in Radian’); xlabel('Normalised frequency');
Frequency response of the designed filter
Practice Problems