Algorithm
- Enter the pass band ripple (rp) and stop band ripple (rs).
- Enter the pass band frequency (wp) and stop band frequency(ws).
- Get the sampling frequency (fs).
- Calculate normalized pass band frequency, and normalized stopband frequency w1 and w2respectively.          Â
w1 = 2 * wp/fs           Â
w2 = 2 * ws /fs
- Make use of the following function to calculate order offilter
Butterworth filterorder                      Â
[n,wn]=buttord(w1,w2,rp,rs)
- Design an nth order digital lowpass Butterworthfilter using the following statements. Butterworth filter [b,a]=butter (n, wn)
OR
Design an nth order digitalhigh pass Butterworth filter using the following statement.Butterworth filter [b,a]=butter (n, wn,’high’)
- Find the digital frequency response of the filter by using‘freqz( )’ function
[H,w]=freqz(b,a,512,fs)
- Calculate the magnitude of the frequency response in decibels(dB)
mag=20*log10 (abs (H))
- Plot the magnitude response [magnitude in dBversus normalizedfrequency (Hz)]
- Calculate the phase response using an = angle (H)
- Plot the phase response [phase in radians Vs normalizedfrequency (Hz)]
Program
Output