LAB 3: Difference Equations, Z-Transforms, Pole-Zero Diagrams, Bibo Stability and Quantization Effects
LAB 3: Difference Equations, Z-Transforms, Pole-Zero Diagrams, Bibo Stability and Quantization Effects
Lise Safatly
This lab was prepared by:
University of Illinois at Urbana-Champaign
Department of Electrical and Computer Engineering
Chandra Radhakrishnan
Peter Kairouz
1 Overview
In this lab we will use MATLAB to solve difference-equations, analyze the stability of LSI systems in terms of the
pole-zero location of their transfer function, and study the effects of quantization on different filter structures.
2 The z-Transform
The bilateral z transform of a discrete-time signal x[n],
∞
X
X(z) = x[n]z −n ,
n=−∞
is a generalization of the discrete-time Fourier transform that is useful for studying discrete-time signals and systems.
Note that if z = ejω , the z-transform reduces to the discrete-time Fourier transform. However, the bilateral z-transform
exists for a broader class of signals than the discrete-time Fourier transform does, and is useful for understanding the
behavior of both stable and unstable systems. For a large class of signals, the z-transform can be represented as a ratio
of polynomials in z, i.e.,
N (z)
X(z) =
D(z)
These transforms are called rational transforms and arise as the system functions of LTI systems which satisfy linear
constant-coefficient difference equations. The locations of the roots N (z) and D(z), known as the zeros and poles of
the system, respectively, determine to within a constant multiplicative factor the behavior of LTI systems with rational
transforms. Therefore, plots of the pole and zero locations can be used to analyze system properties.
1
>> b = [1 -1 0]
>> a = [1 3 2]
>> zs = roots(b)
>> zs =
0
1
>> ps = roots(a)
ps =
-2
-1
It is often desirable to write discrete-time system functions in terms of increasing order of z −1 . The coefficients of these
polynomials are easily obtained from the linear constant coefficient difference equation and are also in the form that
filter requires. However, if the numerator and denominator do not have same order, some poles or zeros at z = 0 may
be overlooked. Example (1) can be rewritten as,
1 − z −1
H(z) = (2)
1 + 3z −1 + 2z −2
If we now use the roots command we will get,
>> b = [1 -1]
>> a = [1 3 2]
>> zs = roots(b)
>> zs =
1
>> ps = roots(a)
ps =
-2
-1
Note that z = 0 does not appear here. In order to find the complete set of poles and zeros when working with a system
function in terms of z −1 , you must append zeros to the coefficient vector for the lower order polynomial such that the
coefficient vectors are the same length. The function dpzplot(a,b) plots the poles and zeros of discrete-time systems.
function dpzplot(b,a)
%dpzplot(b,a)
%plots the pole-zero diagram for the discrete-time system function
%H(z)=b(z)/a(z) defined by numerator and denominator polynomials b and a.
la = length(a);
lb = length(b);
if(la>lb)
b = [b zeros(1,la-lb)];
elseif (lb > la)
a = [a zeros(1,lb-la)];
end
ps = roots(a);
zs = roots(b);
2
mx = max(abs([ps’ zs’ 0.95])) + 0.5;
clf
axis([-mx mx -mx mx]);
axis(’equal’);
hold on
w = [0 : 0.01:2*pi];
plot(cos(w),sin(w),’.’);
plot([-mx mx],[0 0 ]);
plot([0 0], [-mx mx]);
text(0.1,1.1,’Im’,’sc’);
text(1.1,0.1,’Re’,’sc’);
plot(real(ps),imag(ps),’x’);
plot(real(zs),imag(zs),’o’);
numz=sum(abs(zs)==0);
nump=sum(abs(ps)==0);
if numz > 1
text(-0.1,-0.1,num2str(numz));
elseif nump>1
text(-0.1,-0.1,num2str(nump));
end
holdoff
A causal LTI system is one whose unit sample response h[n] satisfies the condition
h[n] = 0, n<0
We also know that the ROC of the z-transform of a causal sequence is the exterior of a circle. Consequently, a linear
time-invariant system is causal if and only if the ROC of the system function is the exterior of a circle or radius r < ∞
including the point z = ∞. The stability of a LTI system can also be expressed in terms the characteristics of the
system function. The necessary and sufficient condition for a LTI system to be BIBO stable is
∞
X
|h[n]| ≤ ∞
n=−∞
In turn, this condition implies that H(z) must contain the unit circle. Hence if the system is BIBO stable, the unit
circle is contained in the ROC of H(z). The converse is also true. Therefore, a linear time-invariant system is BIBO
stable if and only if the ROC of the system function includes the unit circle. Note that ROC cannot contain any poles
of H(z) and if we also consider the ROC of a causal system then it follows that a causal LTI system is BIBO stable if
and only if all the poles are inside the unit circle.
4 Quantization
So far we have assumed that we are dealing with discrete-time systems characterized by linear difference equations with
constant coefficients, where both the coefficients and signal variables have infinite precision. However, when implemented
in either software form in general purpose computer or in special purpose hardware form, the system parameters along
with the signal variables can take only discrete values within specified range since the registers of the digital machine
where they are stored are of finite length.
The function ellip can be used to design a discrete-time elliptic filter. Elliptic frequency selective filters have a frequency
response magnitude which is equiripple in the pass-band, i.e., the frequency response magnitude oscillates between 1±δ1
in the pass-band and between δ2 in the stop band. Consider an eighth order elliptic filter returned by the call,
3
>>[b,a] = ellip(4,0.2,40,[0.41 0.47]);
This filter has 0.2 dB ripple in pass-band, 0.41π ≤ |ω| ≤ 0.47π and has 40 dB attenuation in the stopband. When
discrete-time filters are implemented with quantized coefficients the resulting systems are called digital filters. Digital
filters are generally implemented using fixed-point arithmetic on integer digital signal processing (DSP) chips. The
coefficients of digital filter must be quantized to the number of bits available on the DSP chip. The function quant
below will quantize the coefficients in the vector x to N bits, where M is the maximum possible amplitude of each element.
function qc = quant(x,N,M)
% QUANT Q = QUANT(x,N,M) quantizes the values of x(n) into
% 2^N values. The argument M is the value of the
% maximum amplitude of x[n]
for k = 1 : mm
tmp = fix((x(k,:)+M)./(M/levels));
q = zeros(1,nn);
q(tmp <= maxlevel) = tmp(tmp <= maxlevel);
q(tmp > maxlevel) = maxlevel * ones(1,length(tmp(tmp>maxlevel)));
q(tmp < 0) = zeros(size(tmp(tmp < 0)));
q = (q- levels)*M/levels;
qc(k,:)=q;
end
Coefficient quantization can have an impact on the frequency response magnitude of the elliptic filter. In problem 3 we will
look at two different implementations (Direct Form II and Cascade form) of filters and study the effects of quantization on
these implementations. Note: the function filter in MATLAB uses direct form structure.
5 Homework
1. Consider the following difference equation
(a) Write a function y=diffeqn(a,x,yn1) which computes the output y[n] of the causal system determined by
the given equation. The input vector x contains x[n] for 0 ≤ n ≤ N − 1 and yn1 supplies the values of y[−1].
The output vector y contains y[n] for 0 ≤ n ≤ N − 1. The first line of your M-file should read,
function y = diffeqn(a,x,yn1)
(b) Assume a = 1, y[−1] = 0, and that we are only interested in the output over the interval 0 ≤ n ≤ 30. Use
your function to compute the response due to x1 [n] = δ[n] and x2 [n] = u[n], the unit impulse and unit step,
respectively. Plot each response using stem.
(c) Assume again that a = 1, but that y[−1] = −1. Use your function to compute y[n] over 0 ≤ n ≤ 30 when the
inputs are x1 [n] = u[n] and x2 [n] = 2u[n]. Define the outputs produced by the two signals to be y1 [n] and
y2 [n], respectively. Use stem to plot (2y1 [n] − y2 [n]). Given that the equation is a linear difference equation,
why isn’t this difference identically zero? 4
(d) When is the causal system described by the given difference equation BIBO stable? Assume a = 1/2 and
that x contains x[n] = u[n] for 0 ≤ n ≤ 30. Assuming both y[−1] = 0 and y[−1] = 1/2, compute the two
output signals y[n] for 0 ≤ n ≤ 30. Use stem to display both responses. How do they differ?
2. In this problem we will use dpzplot function to plot the poles and zeros of some rational functions.
z2 − z
H(z) =
z 2 + 3z + 2
(b) Use dpzplot to plot the poles and zeros which satisfy the following difference equation
(c) Use dpzplot to plot the poles and zeros which satisfy the following difference equation
Deliverables
• Submit your code, figures, calculation and answers as a .pdf or .doc file to teams.
• Make sure to present a clear and concise report having figures labeled and centered.