LOMA, Keith Nicole S.
ECE107L / B1
Experiment 4 – Familiarization of Infinite Impulse Response (IIR) and Pole-Zero Response Filters
1.) Using Butterworth filter, design a low pass filter with a sampling rate of 30,000 Hz and a cutoff
frequency of 5000 Hz and stop band frequency of 10,000 Hz. Use Rp = 0.1, Rs = 60. Determine values
for the following:
Syntax:
fs = 30000;
fc = 5000;
fsb = 10000;
wp = 2*fc/fs;
ws = 2*fsb/fs;
rp = 0.1;
rs = 60;
[N,wn] = buttord(wp,ws,rp,rs)
[b,a] = butter(N,wn)
Filter Order: 8
Filter Coefficients:
B = 0.0023 0.0186 0.0652 0.1305 0.1631 0.1305 0.0652 0.0186 0.0023
A = 1.0000 -1.5650 2.0512 -1.4970 0.8488 -0.3101 0.0797 -0.0119 0.0008
2.) Plot the poles and zeroes on the unit circle. Is the plot different from FIR filters? Explain.
Pole Zero Plot
Syntax:
zplane(b,a)
1
0.8
0.6
0.4
0.2
Imaginary Part
-0.2
-0.4
-0.6
-0.8
-1
-1 -0.5 0 0.5 1
Real Part
Magnitude & Phase Response
Syntax:
freqz(b,a)
-50
-100
Magnitude (dB)
-150
-200
-250
-300
-350
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
Normalized Frequency ( rad/sample)
-100
-200
Phase (degrees)
-300
-400
-500
-600
-700
-800
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
Normalized Frequency ( rad/sample)
Explain:
Yes, the produced plots differ from FIR. This is because the average sum of the previous sample
was used as the points of the FIR.
3.) With the same order and cutoff frequency, design a low pass Chebychev type 1 filter and
superimpose its magnitude response to the magnitude response of the Butterworth filter. What do you
observe?
Syntax:
[b1,a1] = cheby1(N,rp,wn)
b1 =
Columns 1 through 5
0.0006 0.0047 0.0164 0.0329 0.0411
Columns 6 through 9
0.0329 0.0164 0.0047 0.0006
a1 =
Columns 1 through 5
1.0000 -3.3465 6.5391 -8.5208 7.9732
Columns 6 through 9
-5.3937 2.5682 -0.7890 0.1215
Magnitude & Phase Response
Syntax:
freqz(b,a)
0
-50
-100
Magnitude (dB)
-150
-200
-250
-300
-350
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
Normalized Frequency ( rad/sample)
-100
-200
Phase (degrees)
-300
-400
-500
-600
-700
-800
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
Normalized Frequency ( rad/sample)
Syntax:
hold on
freqz(b1,a1)
0.1
0
Magnitude (dB)
-0.1
-0.2
-0.3
0.05 0.1 0.15 0.2 0.25 0.3 0.35 0.4 0.45
Normalized Frequency ( rad/sample)
-100
-200
Phase (degrees)
-300
-400
-500
-600
-700
-800
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
Normalized Frequency ( rad/sample)
What do you observe:
It can be observed in the Chebychev plot a visible ripple as compared to the smooth plot of the the
Butterworth.
4.) Using a Chebychev type 2, design a low pass filter with cutoff frequency of 5000 Hz, sampling
frequency of 30,000 Hz and an attenuation of greater than or equal 30 dB at 7500 Hz. Generate its
frequency response and pole-zero plot.
Syntax:
fs = 30000;
fc = 5000;
fsb = 7500;
rs = 60;
rp = 0.1;
wp = fc/(fs/2);
ws = fsb/(fs/2);
[N,wn] = cheb2ord(wp,ws,rp,rs);
[f,e] = cheby2(N,rs,wn);
Pole Zero Plot
Syntax:
zplane(f,e)
0.8
0.6
0.4
0.2
Imaginary Part
-0.2
-0.4
-0.6
-0.8
-1
-1 -0.5 0 0.5 1
Real Part
Magnitude & Phase Response
Syntax:
freqz(f,e)
-20
Magnitude (dB)
-40
-60
-80
-100
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
Normalized Frequency ( rad/sample)
0
Phase (degrees)
-200
-400
-600
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
Normalized Frequency ( rad/sample)
5.) Create a test signal with 2000 sample points. Add five sinusoidal waves with amplitude of 2V and
frequencies of 2kHz, 3.7kHz, 6kHz, 7kHz, and 9kHz. Using sampling frequency of 20kHz, plot its
frequency spectrum.
Syntax:
t = [0:1999]/(20000/2);
y1 = 2*sin(2*pi*2000*t);
y2 = 2*sin(2*pi*3700*t);
y3 = 2*sin(2*pi*6000*t);
y4 = 2*sin(2*pi*7000*t);
y5 = 2*sin(2*pi*9000*t);
ytest = randn(1,2000)+y1+y2+y3+y4+y5;
plot(t,ytest)
10
-2
-4
-6
-8
-10
0 0.02 0.04 0.06 0.08 0.1 0.12 0.14 0.16 0.18 0.2
plot(w,abs([z(1:256)]))
z = fft(ytest,512);
w = (0:255)/256*(20000/2);
plot(w,abs([z(1:256)]))
500
450
400
350
300
250
200
150
100
50
0
0 1000 2000 3000 4000 5000 6000 7000 8000 9000 10000
6.) Design a multiple bandpass filter with sampling frequency of 20,000 Hz, pass band frequency of
3000, 6500, and 8500 Hz and stop band frequency of 0, 4800, 7200, and 10,000 Hz.
Syntax:
Fs = 20000;
pole1 = 3000*(2*pi/Fs);
pole2 = 6500*(2*pi/Fs);
pole3 = 8500*(2*pi/Fs);
[x,y] = pol2cart(pole1,-1.25);
p1 = x+y*i;
[x,y] = pol2cart(pole2,-0.11);
p2 = x+y*i;
[x,y] = pol2cart(pole3,0.21);
p3 = x+y*i;
P = ([p1 conj(p1) p2 conj(p2) p3 conj(p3)])
B = poly(P)
zero1 = 0;
zero2 = 4800*(2*pi/20000);
zero3 = 7200*(2*pi/20000);
zero4 = 10000*(2*pi/20000);
[x,y] = pol2cart(zero1,0.91);
z1 = x+y*i;
[x,y] = pol2cart(zero2,0.98);
z2 = x+y*i;
[x,y] = pol2cart(zero3,0.928);
z3 = x+y*i;
[x,y] = pol2cart(zero4,0.776);
z4 = x+y*i;
Z = ([z1 z2 conj(z2) z3 conj(z3) z4 conj(z4)])
A=poly(Z)
Determine the following values:
Roots for Poles:
Columns 1 through 2
-0.7347 - 1.0113i -0.7347 + 1.0113i
Columns 3 through 4
0.0499 - 0.0980i 0.0499 + 0.0980i
Columns 5 through 6
-0.1871 + 0.0953i -0.1871 - 0.0953i
Roots for Zeroes:
Columns 1 through 2
0.9100 + 0.0000i 0.0615 + 0.9781i
Columns 3 through 4
0.0615 - 0.9781i -0.5915 + 0.7150i
Columns 5 through 6
-0.5915 - 0.7150i -0.7760 + 0.0000i
Column 7
-0.7760 - 0.0000i
Multiple Bandpass Filter Coefficients:
Columns 1 through 5
1.0000 1.7438 1.9845 0.4564 0.0301
Columns 6 through 7
0.0010 0.0008
A=
Columns 1 through 5
1.0000 1.7020 1.5464 0.6995 -0.4502
Columns 6 through 8
-1.2221 -1.2346 -0.4532
7.) Generate its frequency response and pole-zero plot.
Pole Zero Plot
Syntax:
zplane(A,B)
0.8
0.6
0.4
0.2
Imaginary Part
2
0
-0.2
-0.4
-0.6
-0.8
-1
-1 -0.5 0 0.5 1
Real Part
Magnitude & Phase Response
Syntax:
freqz(B,A)
25
20
15
Magnitude (dB)
10
-5
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
Normalized Frequency ( rad/sample)
100
0
Phase (degrees)
-100
-200
-300
-400
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
Normalized Frequency ( rad/sample)
8.) Filter the test signal using the multiple band pass filter.
Syntax:
signalfilter = filter(B,A,ytest);
yfilter = fft(signalfilter,512);
w = (0:255)/256*(Fs/2);
plot(w,abs([yfilter(1:256)]))
9.) Generate the frequency spectrum of the filtered signal. Plot output waveform below. What do you
observe?
Frequency Spectrum:
900
800
700
600
500
400
300
200
100
0
0 1000 2000 3000 4000 5000 6000 7000 8000 9000 10000