题目
题目
• Please note that you are allowed to only use a sheet of notes. No other material (internet, homework
solutions ...) can be used. Please hand in the sheet of notes along with your answer sheets.
• You are allowed to use a calculator for simple calculation purposes only.
Good luck.
KEN
Y n
Ii y É
3 O
09 l
E v n p uz
330
8
É V
1. Consider the real, causal, stable, linear time-invariant filter given by the signal flow graph above (All
nodes are summing nodes). 20 points
(a) Find the difference equation and transfer function of the filter? 7 points
(b) Is the filter FIR or IIR? 2 points
(c) Draw a direct form II implementation of the filter? 5 points
(d) Draw a cascade implementation of the filter preferably with 3 delays. (Useful Identity: 1 + 3z −1 +
3z −2 + z −3 = (1 + z −1 )3 .) 6 points
2. Let h[n] be the impulse response of a stable, causal, LTI filter. The sequence x[n] is constructed as
follows 15 points
∞
X
x[n] = h[n + m]h∗ [m].
m=0
3. An analog Butterworth lowpass filter with parameters N = 16 and Ωc = 1 along with the bilinear
transformation, with Td = 2, is used to design a digital lowpass filter. 15 points
(a) Determine the transfer function of the analog Butterworth filter. Provide it in Cascade form.
(Need not calculate the filter coefficients, but your solution must have enough detail that it is
easily computable) 6 points
(b) Find the normalized digital frequency ωc that the analog frequency Ωc maps to and the magnitude
of the transfer function. 4 points
(c) If the digital filter has a passband ripple of δ1 = .01 and minimum stopband attenuation of
δ2 = .005, find the digital passband and stopband edge frequencies ωp and ωs . (It is sufficient to
provide the equations with proper explanation that will be used to find them) 5 points
1
MIDTERM SOLUTION 2021
1a)
B(z) 1 + 3z −1 + 3z −2 + z −3
H(z) = =
A(z) 1 + 0.9z −1 + 0.81z −2
A(z) = 1 + 2r cos θz −1 + r2 z −2
= 1 + 0.9z −1 + 0.81z −2
r = 0.9
1c)
1
1d)
3 2
(1 + z −1 ) −1
−1 (1 + z )
H(z) = = 1+z
1 + ·9z −1 + 81z −2 A(z)
(1 + 2z −1 + z −2 )
−1
= 1+z
| {z } A(z)
H1 (z) | {z }
H2 (z)
2
2a)
X
x[n] = h[n + m]h∗ [m]
m
= H(z)H ∗ (1/z ∗ )
For the 2nd term, ROC: 1/|z| > rR or |z| < 1/rR
Since rR < 1, 1/rR > 1, the unit circle is included in ROC. So the Fourier transform exists.
jω
jω
∗ 1
X e =H e H
e−jω
= H ejω H ∗ ejω
2
= H ejω
3
3,
3a)
2π 2π
The Butterworth filter has 32 poles, on the circle of radius 1. Angular spacing 2N
= 32
.
pk = Ωc ejθk = 1 · ejθk
= s2 − 2 cos θk s + 1
ΩNc
Hc (s) = Q8
2
k=1 (s − 2 cos θk s + 1)
1
= Q8
2
k=1 (s − 2 cos θk s + 1)
4
3b)
1
|Hc (jΩ)|2 = 2N
Ω
1+ Ωc
1
=
1 + Ω32
Bilinear transformation with Td = 2
2 ω ω
Ω= tan = tan
Td 2 2
ωc
Ωc = 1 = tan
2
ωc π π
=⇒ or ωc =
2 4 2
1
ejωc |2 = |Hc (jΩc )|2 =
|Hd
1 + 132
1
=
2
1
Hd ejωc
=√
2
2
ωp 2
Hd ejωp
= Hc j tan
2
1
= ωp 32
= (1 − δ1)2
1 + tan 2
We can solve for ωp using above equation.
Similarly,
2 1
Hd ejωs
2
= = δ2 (1)
ωs 32
1 + tan 2
5
Homework 1
2. Next, use the command zplane to plot the poles and zeros of H(z). Confirm that the roots
on the plot are the same as the ones you got from the roots command. Finally, use the poly
command to convert the roots back to the numerator and denominator polynomials. Do you
get the same coefficients that you started with?
3. Use the freqz command to plot the magnitude and phase responses of H(ejω ). Use N = 1024
points. What kind of filter is H(z)?
4. Use the impz command to plot the first 64 points of the impulse response h[n] corresponding
to H(z). Next, use the filter command to produce the first 64 points of the impulse response.
To do this, create a vector of the first 64 points in the unit impulse function and input it to
filter, along with the numerator and denominator coefficients that describe H(z). Do you get
the same impulse response as from impz?
Next, use freqz to plot the magnitude and phase spectra of the signal. (Hint: since we are
dealing with a finite-length signal, its Z-transform will have a denominator of 1, and the
numerator coefficients will be exactly the original signal).
6. Use the filter command to filter x[n] through H(z), producing an output y[n]. Use stem to
plot x[n] and y[n]. Next, use freqz to plot the magnitude and phase spectra of y[n]. What has
our filter done to this signal?
1
ch02.qxd 9/21/09 4:03 AM Page 23
© 2010 by Oppenheim. Published by Pearson Prentice Hall, Pearson Education, Inc., Upper Saddle River, NJ.
All rights reserved. This material is protected under all copyright laws as they currently exist. No portion of this
material may be reproduced, in any form or by any means, without permission in writing from the publisher.
23
ch02.qxd 9/21/09 4:03 AM Page 25
© 2010 by Oppenheim. Published by Pearson Prentice Hall, Pearson Education, Inc., Upper Saddle River, NJ.
All rights reserved. This material is protected under all copyright laws as they currently exist. No portion of this
material may be reproduced, in any form or by any means, without permission in writing from the publisher.
25
ch02.qxd 9/21/09 4:04 AM Page 32
© 2010 by Oppenheim. Published by Pearson Prentice Hall, Pearson Education, Inc., Upper Saddle River, NJ.
All rights reserved. This material is protected under all copyright laws as they currently exist. No portion of this
material may be reproduced, in any form or by any means, without permission in writing from the publisher.
32
ch02.qxd 9/21/09 4:09 AM Page 41
© 2010 by Oppenheim. Published by Pearson Prentice Hall, Pearson Education, Inc., Upper Saddle River, NJ.
All rights reserved. This material is protected under all copyright laws as they currently exist. No portion of this
material may be reproduced, in any form or by any means, without permission in writing from the publisher.
41
ch02.qxd 9/21/09 4:09 AM Page 42
© 2010 by Oppenheim. Published by Pearson Prentice Hall, Pearson Education, Inc., Upper Saddle River, NJ.
All rights reserved. This material is protected under all copyright laws as they currently exist. No portion of this
material may be reproduced, in any form or by any means, without permission in writing from the publisher.
42
ch02.qxd 9/21/09 4:09 AM Page 53
© 2010 by Oppenheim. Published by Pearson Prentice Hall, Pearson Education, Inc., Upper Saddle River, NJ.
All rights reserved. This material is protected under all copyright laws as they currently exist. No portion of this
material may be reproduced, in any form or by any means, without permission in writing from the publisher.
53
HW1 MATLAB Solution
1. Using the roots command, we see that the zeros are located at: {−1.0000, −0.8120 +
0.5837j, −0.8120 − 0.5837j} and the poles are located at {−0.0537 + 0.7558j, −0.0537 −
0.7558j, 0.2055}.
2. The zeros and poles we obtained from part (1) agree with the plot produced by the
zplane command, displayed below. Using the poly command, we get back the numerator
coefficients {1.0000, 2.6240, 2.6240, 1.0000} and denominator coefficients {1.0000, −0.0982,
0.5521, −0.1180}. Notice that the numerator coefficients have been normalized such
that the first entry is 1. The poly function does this automatically, so the numerator
coefficients have been multiplied by 1/0.1843. Note that this corresponds to changing
the gain of our system.
4. The two impulse responses are seen below (Figure 3). Notice that they match, as
expected.
1
ECE 161A HW1 MATLAB Solution
5. The magnitude and phase spectra plot of the signal x[n] is displayed below (Figure 4).
Notice that x[n] has two strong components, one at a frequency of 0.15 and the other
at 0.75.
6. Plots of the input x[n] and output y[n] (i.e., using stem command), in the time domain,
appear below (Figure 5). The magnitude and phase spectra of y[n] is shown on Figure
6. Notice that the component at 0.15 has been left alone, while the component at
2
ECE 161A HW1 MATLAB Solution
0.75 has been attenuated by around 32 dB. This is as expected, since the magnitude
response of H at 0.15 is close to 1, while at 0.75 it is close to -32 dB.
3
clear
num = [0.1843 0.4836 0.4836 0.1843];
den = [1 -0.0982 0.5521 -0.1180]
% Part (1
roots(num) % Polynomial root
roots(den
% Part (2
figure(1)
zplane(num,den);
title("Roots of H(z)")
poly(roots(num))
poly(roots(den)
% Part (3
figure(2)
freqz(num,den,1024)
title("Spectrum of H");
% Part (4
figure(3)
subplot(2,1,1)
impz(num,den,64)
title("h[n] from impz")
h = filter(num,den,[1;zeros(63,1)]);
subplot(2,1,2)
stem((0:63),h,"filled");
title("h[n] from filter")
xlabel("n (samples)"); ylabel("Amplitude")
axis([0 63 -0.2 0.6]); % [x_min x_max y_min y_max
% Part (5
n = (0:63)
x = cos(0.15*pi*n)+2*cos(0.75*pi*n);
figure(4)
freqz(x,1,1024)
title("Spectrum of x")
axis([0 1 -50 50]);
% Part (6
y = filter(num,den,x)
figure(5)
subplot(2,1,1)
stem(n,x)
title("x[n]")
xlabel("n")
subplot(2,1,2)
stem(n,y)
title("y[n]")
xlabel("n")
figure(6)
freqz(y,1,1024)
title("Spectrum of y")
axis([0 1 -50 50])
;
Homework 2
Problems from text 4.23, 4.24, 4.30 (Do not turn in, just to help with the review)
1. You can use a segment of code like the one that appears below to generate the ”continuous”
signal for plotting:
t = 0 : 0.005 : 10;
f = 6.5;
xc = cos(2 ∗ π ∗ f ∗ t);
What is the frequency of the sinusoid (in Hz)? What we are doing here is actually sampling
the sinusoid at a rate of 200Hz. Since this is much, much higher than the frequency of our
sinusoid, the result will look like a continuous signal when plotted with the ”plot” command.
You can use a statement like the one below to generate a version of the sinusoid sampled with
sampling period T:
n = 0 : T : 10;
xs = cos(2 ∗ π ∗ f ∗ n);
Use a sampling frequency of 10Hz to generate xs[n]. Use the ”subplot”, ”plot” and ”stem”
commands to plot xc(t) and xs[n] on the same figure. Also, plot the frequency response of xc(t)
and xs[n] using freqz (or fft and fftshift ) and specify the sinusoid frequency in terms of Hz or
normalized frequency. Comment on your results.
2. Repeat the above step for four other sampling rates: 5Hz, 8Hz, 13Hz and 20Hz. Comment on
your results. Feel free to changes the number of samples if that helps with obtaining better
plots.
3. Using the original sampling frequency of 10Hz, repeat the first step with the sinusoids fre-
quency set to 3.5Hz and then again at 13.5Hz. Is there any difference between the corre-
sponding discrete-time signals and the one you generated in step 1? If not, why not?
1
xc(t)
1
0.5
-0.5
-1
0 1 2 3 4 5 6 7 8 9 10
t (sec)
xs[n] -- fs = 13Hz
1
0.5
-0.5
-1
0 1 2 3 4 5 6 7 8 9 10
n/fs (sec)
Frequency response of xs[n], fs = 13Hz
50
Magnitude (dB)
-50
0 0.2 0.4 0.6 0.8 1
Normalized Frequency ( rad/sample)
Phase
200
Phase (degrees)
100
-100
0 0.2 0.4 0.6 0.8 1
Normalized Frequency ( rad/sample)
ch04.qxd 9/21/09 6:03 AM Page 199
© 2010 by Oppenheim. Published by Pearson Prentice Hall, Pearson Education, Inc., Upper Saddle River, NJ.
All rights reserved. This material is protected under all copyright laws as they currently exist. No portion of this
material may be reproduced, in any form or by any means, without permission in writing from the publisher.
Problem 4.23
199
ch04.qxd 9/21/09 6:03 AM Page 200
© 2010 by Oppenheim. Published by Pearson Prentice Hall, Pearson Education, Inc., Upper Saddle River, NJ.
All rights reserved. This material is protected under all copyright laws as they currently exist. No portion of this
material may be reproduced, in any form or by any means, without permission in writing from the publisher.
200
ch04.qxd 9/21/09 6:03 AM Page 201
© 2010 by Oppenheim. Published by Pearson Prentice Hall, Pearson Education, Inc., Upper Saddle River, NJ.
All rights reserved. This material is protected under all copyright laws as they currently exist. No portion of this
material may be reproduced, in any form or by any means, without permission in writing from the publisher.
201
ch04.qxd 9/21/09 6:03 AM Page 204
© 2010 by Oppenheim. Published by Pearson Prentice Hall, Pearson Education, Inc., Upper Saddle River, NJ.
All rights reserved. This material is protected under all copyright laws as they currently exist. No portion of this
material may be reproduced, in any form or by any means, without permission in writing from the publisher.
4.24
204
ch04.qxd 9/21/09 6:03 AM Page 211
© 2010 by Oppenheim. Published by Pearson Prentice Hall, Pearson Education, Inc., Upper Saddle River, NJ.
All rights reserved. This material is protected under all copyright laws as they currently exist. No portion of this
material may be reproduced, in any form or by any means, without permission in writing from the publisher.
211
HW2 MATLAB Solution
1. The sinusoid’s frequency is 6.5 Hz.
Notice that the sampling rate is too low to capture the signal. If we were to “connect
the dots”, we’d end up with a 3.5Hz sinusoid, not the 6.5Hz one we started with.
Generally when a sinusoid frequency f is sampled at a rate fs that is below the rate
prescribed by the Nyquist theorem, the apparent frequency of the sampled signal is
|f − fs | which is 3.5Hz in this case. Also from the frequency response plot (Fig.2, right
1
HW2 MATLAB Solution
panel) it can be seen that the peak frequency corresponds to a 3.5Hz signal (0.7 × 10/2)
which is not the 6.5Hz frequency of the original signal.
Figure 3: Plots of xc (t) and xs [n], with varied sampling rates f s =5Hz, 8Hz, 15Hz, 20Hz
The corresponding frequency responses of xs [n] are attached as follows (Fig. 4). Ob-
serve that in the first two plots, the sampling rate is still too low. The first plot (fs =5
Hz) gives a signal with a 0.6 × 5/2 = 1.5Hz and the second one gives 0.37 × 8/2 = 1.48
Hz, as predicted by the equation in part 1. Starting from the third plot, the sam-
pling rate was high enough to accurately portray the signal. Specifically, we have
0.87 × 15/2 = 6.52 Hz for fs = 15 Hz and 0.65 × 20/2 = 6.5 Hz for fs = 20 Hz. If one
were to connect the dots (that is, apply an ideal reconstruction filter), we’d get back
the original signal.
2
HW2 MATLAB Solution
Figure 4: Frequency response of xs [n], with varied sampling rates f s =5Hz, 8Hz, 15Hz, 20Hz.
Plots are produced using ’freqz ’ command
3. In this case, notice that the sampled signals xs [n] (Fig. 5) are both identical, and also
identical to the plot in part 1 (Fig. 1). This can be explained by the periodicity of
the sinusoid signals, given the same sampling frequency fs = 10Hz. Specifically, when
f = 3.5 Hz, xs [n] = cos( 3.5×2πn
10
) = cos( 7πn
10
). When f = 6.5 Hz, xs [n] = cos( 6.5×2πn
10
)=
7πn 7πn 13.5×2πn
cos(− 10 + 2πn) = cos( 10 ). Similarly, when f = 13.5 Hz, xs [n] = cos( 10 ) =
cos( 7πn
10
+ 2πn) = cos( 7πn
10
).
3
HW2 MATLAB Solution
Figure 5: Plots of xc (t) and xs [n] with f = 3.5, 13.5 Hz using the same fs = 10 Hz.
4
close all
clear
%% part
t = 0:0.005:10
f = 6.5
xc = cos(2*pi*f*t)
T = 1/10; %Use sampling frequency of 10H
n = 0:T:10
xs = cos(2*pi*f*n)
figure(1
subplot(2,1,1
plot(t,xc)
title('xc(t)')
xlabel('t (sec)')
subplot(2,1,2
stem(n,xs)
title('xs[n] -- fs = 10Hz')
xlabel('n/fs (sec)')
figure(2)
freqz(xc,1,1024);title("Frequency response of xc(t)")
figure(3)
freqz(xs,1,1024);title("Frequency response of xs[n], fs = 10Hz")
%% part
%fs = 5H
T = 1/5;
n = 0:T:10
xs = cos(2*pi*f*n)
figure(4
subplot(2,1,1
plot(t,xc);
title('xc(t)')
xlabel('t (sec)')
subplot(2,1,2
stem(n,xs);
title('xs[n] -- fs = 5Hz')
xlabel('n/fs (sec)')
figure(5)
freqz(xs,1,1024);title("Frequency response of xs[n], fs = 5Hz")
set(findall(gcf,'-property','FontSize'),'FontSize',16)
%fs = 8H
T = 1/8;
n = 0:T:10
xs = cos(2*pi*f*n)
figure(6
subplot(2,1,1
plot(t,xc);
title('xc(t)')
xlabel('t (sec)')
subplot(2,1,2
stem(n,xs);
title('xs[n] --fs = 8Hz')
xlabel('n/fs (sec)')
figure(7)
freqz(xs,1,1024);title("Frequency response of xs[n], fs = 8Hz")
%fs = 15H
T = 1/15;
n = 0:T:10
xs = cos(2*pi*f*n)
figure(8
subplot(2,1,1
plot(t,xc);
title('xc(t)')
;
xlabel('t (sec)');
subplot(2,1,2)
stem(n,xs);
title('xs[n] -- fs = 15Hz');
xlabel('n/fs (sec)');
figure(9);
set(findall(gcf,'-property','FontSize'),'FontSize',16);
%fs = 20Hz
T = 1/20;
n = 0:T:10;
xs = cos(2*pi*f*n);
figure(10)
subplot(2,1,1)
plot(t,xc);
title('xc(t)');
xlabel('t (sec)');
subplot(2,1,2)
stem(n,xs);
title('xs[n] -- fs = 20Hz');
xlabel('n/fs (sec)');
figure(11);
%% part 3
%3.5Hz
t = 0:0.005:10;
f = 3.5;
xc = cos(2*pi*f*t);
n = 0:T:10;
xs = cos(2*pi*f*n);
figure(12)
subplot(2,1,1)
plot(t,xc);
xlabel('t (sec)');
subplot(2,1,2)
stem(n,xs);
title('xs[n] –- fs = 10Hz');
xlabel('n/fs (sec)');
set(findall(gcf,'-property','FontSize'),'FontSize',16);
%13.5 Hz
t = 0:0.005:10;
f = 13.5;
xc = cos(2*pi*f*t);
n = 0:T:10;
xs = cos(2*pi*f*n);
figure(13)
subplot(2,1,1)
plot(t,xc);
subplot(2,1,2)
stem(n,xs);
Homework 3
© 2010 by Oppenheim. Published by Pearson Prentice Hall, Pearson Education, Inc., Upper Saddle River, NJ.
All rights reserved. This material is protected under all copyright laws as they currently exist. No portion of this
material may be reproduced, in any form or by any means, without permission in writing from the publisher.
113
3.3 (c)
1
ch03.qxd 9/21/09 4:46 AM Page 132
© 2010 by Oppenheim. Published by Pearson Prentice Hall, Pearson Education, Inc., Upper Saddle River, NJ.
All rights reserved. This material is protected under all copyright laws as they currently exist. No portion of this
material may be reproduced, in any form or by any means, without permission in writing from the publisher.
132
ch03.qxd 9/21/09 4:46 AM Page 133
© 2010 by Oppenheim. Published by Pearson Prentice Hall, Pearson Education, Inc., Upper Saddle River, NJ.
All rights reserved. This material is protected under all copyright laws as they currently exist. No portion of this
material may be reproduced, in any form or by any means, without permission in writing from the publisher.
133
ch03.qxd 9/21/09 4:46 AM Page 143
© 2010 by Oppenheim. Published by Pearson Prentice Hall, Pearson Education, Inc., Upper Saddle River, NJ.
All rights reserved. This material is protected under all copyright laws as they currently exist. No portion of this
material may be reproduced, in any form or by any means, without permission in writing from the publisher.
143
ch03.qxd 9/21/09 4:47 AM Page 167
© 2010 by Oppenheim. Published by Pearson Prentice Hall, Pearson Education, Inc., Upper Saddle River, NJ.
All rights reserved. This material is protected under all copyright laws as they currently exist. No portion of this
material may be reproduced, in any form or by any means, without permission in writing from the publisher.
167
Homework 4
Book problems: 6.24, 6.28 a, b, (Required to be turned in)
In this problem you have been provided a speech file sampled at 8 kHz
(corrupted_speech.mat). However, it has been corrupted using two tones, i.e
two sinusoids of two different frequencies, and so the speech content is not
recognizable on playback. Your job is to use filtering techniques to eliminate
these two tone frequencies and recognize the content of the speech file. The
following steps will be helpful for this purpose.
© 2010 by Oppenheim. Published by Pearson Prentice Hall, Pearson Education, Inc., Upper Saddle River, NJ.
All rights reserved. This material is protected under all copyright laws as they currently exist. No portion of this
material may be reproduced, in any form or by any means, without permission in writing from the publisher.
421
Ch06.qxd 9/23/09 12:17 AM Page 422
© 2010 by Oppenheim. Published by Pearson Prentice Hall, Pearson Education, Inc., Upper Saddle River, NJ.
All rights reserved. This material is protected under all copyright laws as they currently exist. No portion of this
material may be reproduced, in any form or by any means, without permission in writing from the publisher.
422
Ch06.qxd 9/23/09 12:17 AM Page 423
© 2010 by Oppenheim. Published by Pearson Prentice Hall, Pearson Education, Inc., Upper Saddle River, NJ.
All rights reserved. This material is protected under all copyright laws as they currently exist. No portion of this
material may be reproduced, in any form or by any means, without permission in writing from the publisher.
423
Ch06.qxd 9/23/09 12:17 AM Page 427
© 2010 by Oppenheim. Published by Pearson Prentice Hall, Pearson Education, Inc., Upper Saddle River, NJ.
All rights reserved. This material is protected under all copyright laws as they currently exist. No portion of this
material may be reproduced, in any form or by any means, without permission in writing from the publisher.
427
Ch06.qxd 9/23/09 12:17 AM Page 428
© 2010 by Oppenheim. Published by Pearson Prentice Hall, Pearson Education, Inc., Upper Saddle River, NJ.
All rights reserved. This material is protected under all copyright laws as they currently exist. No portion of this
material may be reproduced, in any form or by any means, without permission in writing from the publisher.
428
ECE MATLAB3 (part of HW4) Solution
1. So, the given speech file has been corrupted using two tone frequencies. Now to identify
these two frequencies we plot the fft of the given corrupted speech sequence. From this
plot, the two tone frequencies can be identified by looking at the peaks of the maginitude
response. These two are: 0.25π and 0.4π (normalized frequency).
2. Now to remove these two frequencies we need to design two notch filters (which will
be in cascade) to remove those specific frequencies. We have already found out that,
ω1 = 0.25π and ω2 = 0.4π. Thus from the definition of the notch filter, the transfer
function of the first notch filter will be,
where, α < 1 is just a constant to put the pole nearby the zero.
3. Now the corrupted speech is passed through this two notch filters and we recover the
original speech, which is “Welcome to ECE”
1
ECE 161A MATLAB3 (part of HW4) Solution
2
clear; clc; close all
load corrupted_speech.mat
figure(1)
freqz(corrupted_speech)
set(findall(gcf,'-property','FontSize'),'FontSize',16)
% H
w_c1 = 0.25 * pi; w_c2 = 0.4 * pi
num1 = [1 -2*cos(w_c1) 1]
denom1 = [1 -2*0.9*cos(w_c1) 0.9^2]
h1 = filter(num1,denom1,[1;zeros(40000,1)]);
figure(2)
freqz(h1)
set(findall(gcf,'-property','FontSize'),'FontSize',16)
y1 = filter(num1,denom1,corrupted_speech)
% H2
num2 = [1 -2*cos(w_c2) 1]
denom2 = [1 -2*0.9*cos(w_c2) 0.9^2]
h2 = filter(num2,denom2,[1;zeros(40000,1)]);
figure(3)
freqz(h2)
set(findall(gcf,'-property','FontSize'),'FontSize',16)
y2 = filter(num2,denom2,y1)
filename = 'speech.wav'
audiowrite(filename,y2,8e3); % Welcome to ECE 161
1
1. To start with, we’ll need an analog filter. Determine the specifications on the analog
filter that correspond to the digital specifications given above. Use the function ellip
to design the filter. You can use ellipord to determine the correct order and cut-off
frequency to give to ellip. Plot the frequency response using freqs, and confirm that
it meets the specifications you worked out. Plot the polezero diagram for the filter.
Since this is an analog filter, don’t use zplane. Instead, use roots to find the poles
and zeros and plot them using plot.
2. Use the bilinear function to transform your analog filter to a digital IIR filter. For this
part, do not use any frequency pre-warping. Plot the frequency response and polezero
diagram of the filter. Also, zoom in on the passband and stopband and determine if
they meet the spec. If not, explain why. We know that the bilinear transform should
map any roots of the analog filter in the left-half s-plane into the interior of the unit
circle in the z-plane. Did this occur?
3. Repeat part 2), but this time use frequency pre-warping to ensure perfect accuracy
at the passband edge frequency. How does the frequency response differ from the
previous case? Does this filter meet the spec? How do the locations of the poles and
zeros compare to part 2)?
4. Use the impinvar function to design a digital IIR filter from the analog filter designed
in part 1) via the impulse invariance method. Show the frequency response and pole-
zero diagram. Explain the differences inpassband and stopband ripple as compared to
the bilinear transform cases. How do the locations of the poles and zeros compare to
the bilinear transform cases? Were zeros on the imaginary axis in the splane mapped
to the unit circle in the z-plane?
5. Repeat steps 1) and 3) using a Butterworth and Chebyshev type 1 filter. You can use
the functions buttord, cheb1ord and butter,cheby1 to design the analog filter. Do
the resulting filters meet the spec?Also, compare the order of the filters you get to the
order of the one in part 1).
1
----
Digital Elliptical Filters
--Biinear, noprewarping-
-10 1 -- Biinear, prewarping
-- Impulse I nVc1riance
-30 dB
-40
-50'-----_,______,.___--'-"-_-'--'-------'---'_.__.,____---L..____-'--_
0.5 1.5 2 2.5 3
Frequency (rad)
z-plane
x Bilinear, no prewarping
x Bilinear, prewarping
0.5 Impulse lnVc1riance
-0.5
-1
-3 -2 -1 0 2 3
Re(z)
N_Ellip = 4
Here, we see that without prewarping the frequencies, the bilinear transformation fails to
meet the specs {it starts falling off too early). This is because the analog specs we used for the
analog filter design do not map to the digital specs given to us without prewarping. If we do
prewarp the frequencies, however, we do meet our spec. The poles in both cases get
mapped to inside the unit circle, but when we use prewarping, the poles and zeros are
slightly different since we are now using the correct frequency mapping.
When we use impulse invariance, we see that the spec is not met in the stopband due to
aliasing. We do, however, meet our passband spec. We have a zero from the imaginary axis
on the analog filter mapped to far outside the unit circle in the digital filter using this method.
Digital Butterworth Filters
0 .------------s:--.._ I I
- - -3dB- - - - - --Biinear, noprewarping-
-10 -- Biinear, prewarping
1
-- impulse Invariance
� -20
-0
.2
.§i
�
ro
-30
-40
-30 dB
_, I 00s
I
_______ _
\�\
.50�---�----�-�-��-�-�----�----�-
0.5 1.5 2 2.5 3
Frequency (rad)
z-plane
x Bilinear, no prewarping
x Bilinear, prewarping
0.5 Impulse Invariance
0
0 0 0
0
-0.5
)( X
-1
-3 -2 -1 0 2
Re(z)
N_Butter = 11
Here, once again without prewarping we do not meet our spec. However, here both bilinear
with prewarping and the impulse invariance meet the spec. Beca use Butterworth filters
overshoot so much, aliasing is not as much of a factor. However, the order of the filter is
much higher, and the O's are mapped all over the place.
Digital Chebyshev Filters
0
-- -- -- - --Biinear, noprewarping-
-- Biinear, prewarping
-10 1 -- Impulse I nVclriance
I"\
.3
c)
-4 0
-50'-------"------'---_.____..___,_,_____,___,_____--'------'--
0.5 1.5 2 2.5 3
Frequency (rad)
z-plane
x Bilinear, no prewarping
x Bilinear, prewarping
0.5 Impulse lnVclriance
0 C)
-0.5
-1
-3 -2 -1 0 2
Re(z)
N_Cheby = 5
Once again, we see the same trends - the bilinear filter with prewarping and impulse
invariance both meet the spec. This filter has a constant rolloff, but has ripples in the
passband. Because of the rolloff, aliasing is not a factor in meet ing the spec. The order of
this filter is only slightly higher than that of the elliptical filter because we allow for ripples in
the passband (Butterworth just has a constant dropoff).
Homework 5 - Theory
Problem 3: Design a IIR filter to match the specs in 7.16, Use Butterworth analog filters and
bilinear transformation. Do not use the Matlab programs for filter design for this problem.
Problem 4: Starting from a lowpass digital filter 𝜔𝜔𝑝𝑝 , 𝜔𝜔𝑠𝑠 , 𝛿𝛿1 , 𝛿𝛿2 , an analog low pass filter H1(s) is
designed using pre-warping with Td=T1. A second lowpass filter H2(s) is designed using pre-
warping with Td=T2.
• Show that an analog filter H2(s) for Td=T2 that matches the specifications can be
simply obtained from H1(s) using a simple transformation, i.e. change of variables.
• Using the above result, show that the digital filter H(z) will be the same starting from
H1(s) and H2(s), once we apply the appropriate bilinear transformation.
7.26 Problem 1
7.26 (b) cont’d
Problem 2
HW4 problem 4 solution
Problem 3
4. From problem 7.16 the specs for the digital low pass filter is given as,
0.98 < H(ej! ) < 1.02, f or0 |!| 0.63⇡ (1)
0.15 < H(ej! ) < 0.15, f or0.65⇡ |!| ⇡ (2)
Now our job is to design a butterworth analog filter first, and then we will convert it to our
digital filter using bilinear transformation. For that we have to use the proper mapping for
the frequency.
So now the specification of analog filter will be,
2 0.63⇡
0.98 < |H(j⌦)| < 1.02, 0 ⌦| tan( ) (3)
Td 2
2 0.65⇡
|H(j⌦)| < 0.15, tan( ) |⌦| 1 (4)
Td 2
Now using Td = 1 the design constraints become,
0.63⇡
|Hc (j2 tan | 0.98 (5)
2
0.65⇡
|Hc (j2 tan | 0.15 (6)
2
Now for the butterworth filter, using this |H(j⌦)|2 = 1
1+( ⌦⌦c )2N
and solving the above
discussed design constraints we get N = 50.1085, after rounding off N ⇠ 51.
Using this value of N and satisfying the stopband conditions we get, ⌦c = 3.1452.
Now we will assign the poles residing in the left hand side of the s plane to our Hc (s),
which will look like,
Hc (s) = 15
Q O
constant NI (7)
k (s ⌦c exp(j✓k )))(s ⌦c exp( j✓k )))
Where ✓k s can be found by fixing one pole at the angle of ⇡2 + 2N
⇡
yy
and then placing other
poles with an angle difference of N .
⇡
Now we will use billinear transformation to get the transfer function of our digital filter
with a simple change of variable,
1
1 z
H(z) = Hc (2 1
) (8)
1+z
D
E K
E
On et K 1 25
below
1
5 He s has 25 complex pairs f one real
a total of 51 root
A 61
stiffening.é
Fitt
HM
A.fi
YITFED
Each of second order terms is tractable
2 1 − z −1
H̃2 (z) = H2 ( )
T2 1 + z −1
(4)
T2 2 1 − z −1
= H1 ( )
T1 T2 1 + z −1
2 1 − z −1
= H1 ( )
T1 1 + z −1
= H̃1 (z)
Note: You do NOT need to solve 7.16. However, you will need the specs in 7.16 to solve
Problem 3 in “Homework 5 – Theory”.