Professional Documents
Culture Documents
NO: 5
OBJECTIVE: To write a MATLAB program to design impulse invariant filters. EQUIPMENTS AND ACCESSORIES REQUIRED: MATLAB 7 ALGORITHM: 1. Get the pass band, stop band, pass band attenuation, stop band attenuation and sampling frequency. 2. Calculate the value of p = (2*fp)/Fs, s = (2*fs)/Fs. 3. Plot the analog low pass filter using butter function, digital impulse invariant filter using impinvar function, digital bilinear filter using bilinear function. 4. Plot the analog high pass filter using butter function. PROGRAM: clc; clear all; close all; fp=input('Enter PassBand Frequency'); fs=input('Enter StopBand Frequency'); rp=5; rs=50; f=input('Enter sampling freq'); wp=(2*fp)/f; ws=(2*fs)/f; [N wn]=buttord(wp,ws,rp,rs); [b a]=butter(N,wn,'s'); figure(1); freqs(b,a); title('Analog- Low pass filter'); [b1 a1]=impinvar(b,a); figure(2); freqz(b1,a1); title('Digital Low Pass Filter using Impulse invariant method'); [b2 a2]=bilinear(b,a,f); figure(3); freqz(b2,a2); title('Digital Low Pass Filter using Bilinear transformation'); plot(omega,phase); grid; title('phase plot');
OBSERVATION: Enter PassBand Frequency1000 Enter StopBand Frequency2000 Enter sampling freq10000
1 0 M g itu e a n d
0
1 0
1 0
1 0
P a h se (d g e e re s)
20 0 10 0 0 -0 10 -0 20 2 1 0
1 0
Digital Low Pass Filter using Impulse invariant method 100 Magnitude (dB)
-100
-200
0.1
0.2
0.9
0.1
0.2
0.9
Digital Low Pass Filter using Bilinear transformation 200 Magnitude (dB)
-200
-400
0.1
0.2
0.8
0.9
300
200
100
0.1
0.2
0.8
0.9
PROGRAMHIGHPASS IIR
clc; clear all; close all; fp=input('Enter PassBand Frequency'); fs=input('Enter StopBand Frequency'); rp=5; rs=50; f=input('Enter sampling freq'); wp=(2*fp)/f; ws=(2*fs)/f; [N wn]=buttord(wp,ws,rp,rs); [b a]=butter(N,wn,'high','s'); figure(1); freqs(b,a); title('Analog -High pass filter'); [b1 a1]=impinvar(b,a); figure(2); freqz(b1,a1); title('Digital High Pass Filter using Impulse invariant method'); [b2 a2]=bilinear(b,a,f); figure(3); freqz(b2,a2); title('Digital High Pass Filter using Bilinear transformation');
OBSERVATION: Enter PassBand Frequency 1000 Enter StopBand Frequency2000 Enter sampling freq10000
10
0
Magnitude
10
-5
10
-10
10
-2
10
-1
10 Frequency (rad/s)
10
10
-1
10 Frequency (rad/s)
10
Digital High Pass Filter using Impulse invariant method 10 Magnitude (dB) 0 -10 -20 -30
0.1
0.2
0.9
200
100
0.1
0.2
0.9
Digital High Pass Filter using Bilinear transformation 0.6 Magnitude (dB) 0.4 0.2 0 -0.2
0.1
0.2
0.9
100
-100
0.1
0.2
0.9
RESULT: Thus the digital butter worth IIR filters were designed and executed successfully.