0% found this document useful (0 votes)
132 views4 pages

EXPERIMENT 12: Butterworth Digital LPF: If Else

This document describes experiments to generate the frequency response of Butterworth digital low pass and high pass filters using MATLAB. It provides the algorithm, sample MATLAB code, inputs, outputs, and results of running the code. The algorithm involves defining the passband, stopband frequencies and tolerances, computing the filter order and coefficients, and plotting the magnitude and phase response of the filters.

Uploaded by

appuamreddy
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
132 views4 pages

EXPERIMENT 12: Butterworth Digital LPF: If Else

This document describes experiments to generate the frequency response of Butterworth digital low pass and high pass filters using MATLAB. It provides the algorithm, sample MATLAB code, inputs, outputs, and results of running the code. The algorithm involves defining the passband, stopband frequencies and tolerances, computing the filter order and coefficients, and plotting the magnitude and phase response of the filters.

Uploaded by

appuamreddy
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

S.

SAI VIKRAM

08621A0446

EXPERIMENT 12: Butterworth Digital LPF


Aim:- To write a program to generate the frequency response of butter worth digital LPF using MATLAB. Software tools:- MATLAB 7.0 software. Algorithm:1. Get the value of pass band, stop band frequencies (wp,ws) 2. Normalize the pass band, stop band frequencies (w1,w2) 3. Find the order (N) natural cutoff frequency (wn) using buttord (i/p are w1, w2, rp, rs) 4. Find the butter worth filter analog coefficients (b,a) using butter function input( N, wn, s) 5. Find the butter worth digital low pass coefficients (b1, a1) using bilinear(b,a,2) 6. Find the transfer function (b) using freqz function (i/p are b1, a1, w) 7. Find the gain of the filter using 20*log(abs(h)) 8. Find the phase of the filter using angle(h) 9. Plot the magnitude and phase response of filter. PROGRAM:wp=input('enter the passband frequency');

ws=input('enter the stopband frequency'); rp=input('enter the passband attenuation'); rs=input('enter the stopband attenuation'); fs=input('enter the normalized frequency'); w1=2*wp/fs; w2=2*ws/fs; if (wp>ws) error('For LFP wp should be less than ws'); else [n,wn]=buttord(w1,w2,rp,rs,'s') [b,a]=butter(n,wn,'s') w=0:0.01:pi; [b1,a1]= bilinear(b,a,2); [h,omega]=freqz(b1,a1,w); gain=20*log(abs(h)); an=angle(h); subplot(2,1,1) plot(omega/pi,gain); grid title('magnitude plot'); xlabel('normalized frequency'); ylabel('gain in db'); subplot(2,1,2) plot(omega/pi,an); title('phase plot'); xlabel('normalized frequency'); ylabel('phase angle'); end
31 4th Year,ECE-A DSP LAB

S.SAI VIKRAM

08621A0446

INPUT:enter the passband frequency600 enter the stopband frequency700 enter the passband attenuation2 enter the stopband attenuation10 enter the normalized frequency1000 OUTPUT:n=9 wn =1.2391 b = [0 0 0 0 0 0 0 0 0 6.8870] a = [1.0000 7.1358 25.4600 59.2910 98.9844 122.6539 112.8061 74.3758 32.0071 6.8870] WAVEFORM:-

RESULT:The magnitude and phase response characteristics of digital low pass butter worth filter are computed using MATLAB.

32 4th Year,ECE-A DSP LAB

S.SAI VIKRAM

08621A0446

EXPERIMENT 13: Butterworth Digital HPF


Aim:- To write a program to generate the frequency response of butter worth digital HPF using MATLAB. Software tools:- MATLAB 7.0 software. Algorithm:1. Get the value of pass band, stop band frequencies (wp,ws) 2. Normalize the pass band, stop band frequencies (w1,w2) 3. Find the order (N) natural cutoff frequency (wn) using buttord (i/p are w1, w2, rp, rs) 4. Find the butter worth filter analog coefficients (b,a) using butter function input( N, wn, high, s) 5. Find the butter worth digital low pass coefficients (b1, a1) using bilinear(b,a,2) 6. Find the transfer function (b) using freqz function (i/p are b1, a1, w) 7. Find the gain of the filter using 20*log(abs(h)) 8. Find the phase of the filter using angle(h) 9. Plot the magnitude and phase response of filter. PROGRAM:wp=input('enter the passband frequency'); ws=input('enter the stopband frequency'); rp=input('enter the passband attenuation'); rs=input('enter the stopband attenuation'); fs=input('enter the normalized frequency'); w1=2*wp/fs; w2=2*ws/fs; if (wp<ws) error('For HFP wp should be greater than ws'); else [n,wn]=buttord(w1,w2,rp,rs,'s') [b,a]=butter(n,wn,'high','s') w=0:0.01:pi; [b1,a1]= bilinear(b,a,2); [h,omega]=freqz(b1,a1,w); gain=20*log(abs(h)); an=angle(h); subplot(2,1,1) plot(omega/pi,gain); grid title('magnitude plot'); xlabel('normalized frequency'); ylabel('gain in db'); subplot(2,1,2) plot(omega/pi,an); title('phase plot'); xlabel('normalized frequency'); ylabel('phase angle'); end
33 4th Year,ECE-A DSP LAB

S.SAI VIKRAM

08621A0446

INPUT:enter the passband frequency700 enter the stopband frequency200 enter the passband attenuation2 enter the stopband attenuation10 enter the normalized frequency1000 OUTPUT:n=2 wn = 0.6928 b = [1 0 0] a = [1.0000 0.9798 WAVEFORM:-

0.4800]

RESULT:The magnitude and phase response characteristics of digital high pass butter worth filter are computed using MATLAB.

34 4th Year,ECE-A DSP LAB

You might also like