Butterworth Analog Filters

9
Butterworth Analog Filters 1. Low Pass Butterworth analog Filter- Program: clc; format long rp=input('enter the passpand ripple'); rs=input('enter the stopband ripple'); wp=input('enter the passpand 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); ylabel('Gain in db '); xlabel('(a) normalized frequency'); subplot(2,1,2); plot(om/pi,an); xlabel('(b) Normalized Frequency'); ylabel('Phase in radians');

description

Butterworth Analog Filters

Transcript of Butterworth Analog Filters

Page 1: Butterworth Analog Filters

Butterworth Analog Filters

1. Low Pass Butterworth analog Filter-

Program:

clc; format long rp=input('enter the passpand ripple'); rs=input('enter the stopband ripple'); wp=input('enter the passpand 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); ylabel('Gain in db '); xlabel('(a) normalized frequency'); subplot(2,1,2); plot(om/pi,an); xlabel('(b) Normalized Frequency'); ylabel('Phase in radians');

Page 2: Butterworth Analog Filters

OUTPUT:

enter the passpand ripple 0.15

enter the stopband ripple 60

enter the passpand frequency 1500

enter the stopband frequency 3000

enter the sampling frequency 7000

Graph:

Page 3: Butterworth Analog Filters

2. High Pass Butterworth analog Filter

Program:

clc; close all; clear; format long rp=input('enter the passband ripple '); rs=input('enter the stopband ripple '); wp=input('enter the passband freq '); ws=input('enter the stopband freq '); fs=input('enter the sampling freq '); w1=2*wp/fs; w2=2*ws/fs; [n,wn]=buttord(w1,w2,rp,rs,'s'); [b,a]=butter(n,wn,'high','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); ylabel('Gain in dB-->'); xlabel('(a) Normalised frequency-->'); grid on; subplot(2,1,2); plot(om/pi,an); ylabel('Phase in radians-->'); xlabel('(b) Normalised frequency-->'); grid on;

Page 4: Butterworth Analog Filters

Output:

1.

enter the passband ripple 0.2

enter the stopband ripple 40

enter the passband freq 2000

enter the stopband freq 3500

enter the sampling freq 8000

Graph:

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1-400

-300

-200

-100

0

100

Gain

in d

B--

>

(a) Normalised frequency-->

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1-4

-2

0

2

4

Phase in r

adia

ns--

>

(b) Normalised frequency-->

Page 5: Butterworth Analog Filters

2.

enter the passband ripple 0.40

enter the stopband ripple 60

enter the passband freq 3000

enter the stopband freq 4000

enter the sampling freq 7000

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1-1500

-1000

-500

0

500

Gain

in d

B--

>

(a) Normalised frequency-->

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1-4

-2

0

2

4

Phase in r

adia

ns--

>

(b) Normalised frequency-->

Page 6: Butterworth Analog Filters

3. Band Pass Butterworth analog Filter-

Program

clc close all clear all format long rp=input('enter passband ripple: '); rs=input('enter stopband ripple: '); wp=input('enter passband frequency: '); ws=input('enter stopband frequency: '); fs=input('enter sampling frequency: '); w1=2*wp/fs; w2=2*ws/fs; [n]=buttord(w1, w2, rp, rs, 's'); wn=[w1 w2]; [b, a]=butter(n, wn, 'bandpass', '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); ylabel('Gain in dB'); xlabel('(a) Normalised frequency'); grid on; subplot(2,1,2); plot(om/pi,an); xlabel('(b) Normalised frequency'); ylabel('Phase in radians'); grid on;

Page 7: Butterworth Analog Filters

Output:

enter passband ripple: .36

enter stopband ripple: 36

enter passband frequency: 1500

enter stopband frequency: 2000

enter sampling frequency: 6000

Graph:

Page 8: Butterworth Analog Filters

4. Band stop Butterworth analog Filter

Program:

clc;

close all;

clear all;

format long

rp=input('Enter the passband ripple: ');

rs=input('Enter the stopband ripple: ');

wp=input('Enter the passband freq: ');

ws=input('Enter the stopband freq: ');

fs=input('Enter the sampling freq: ');

w1=2*wp/fs;

w2=2*ws/fs;

[n]=buttord(w1,w2,rp,rs,'s');

wn=[w1,w2];

[b,a]=butter(n,wn,'stop','s');

w=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);

ylabel('Gain in DB-->');

xlabel('(a) Normalised frequency-->');

subplot(2,1,2);

plot(om/pi,an);

xlabel('(b) Normalised frequency-->');

ylabel('Phase in radians-->');

Page 9: Butterworth Analog Filters

Output:

Enter the passband ripple: 0.28

Enter the stopband ripple: 28

Enter the passband freq: 1000

Enter the stopband freq: 1400

Enter the sampling freq: 5000

Graph:

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1-200

-100

0

100

Gain

in

D

B-->

(a) Normalised frequency-->

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1-5

0

5

(b) Normalised frequency-->

Phase in

radia

ns-->