The transfer function is the basic z-domain representation of a a digital filter, expressing the filter as a ratio of two polynomials. The transfer function model description for the z-transform of a difference equation is
The constants b(i) and a(i) are the filter coefficients, stored in two row vectors.
A simple IIR filter is
can be defined in Matlab byb = [2 3 4]; a = [ 1 3 3 1];This example will be used to illustrate other representations of linear systems.
The factored or zero-pole-gain form of a transfer function is
By convention, Matlab stores polynomial coefficients in row vectors and polynomial roots in column vectors. In zero-pole-gain form, therefore, the zero and pole locations for the denominator and numerator of a transfer function reside in column vectors. The factored transfer function gain k is a scalar.
The
poly
and
roots
functions convert between polynomial and zero-pole-gain representations
q = roots(b) q = -0.7500 + 1.1990i -0.7500 - 1.1990i p = roots(a) p = -1.0000 -1.0000 + 0.0000i -1.0000 - 0.0000i k = b(1)/a(1) k = 2
The Matlab signal-processing function
tf2zp
also does transfer function to zero-pole-gain form.
[z, p, k] = tf2zp(b,a) z = -0.7500 + 1.1990i -0.7500 - 1.1990i p = -1.0000 -1.0000 + 0.0000i -1.0000 - 0.0000i k = 2
Returning to the original polynomials:
bb = k*poly(q) bb = 2.0000 3.0000 4.0000 aa = poly(p) aa = 1.0000 3.0000 3.0000 1.0000Note that
b
and a
in this case represent the transfer function
For b = [2 3 4]
, the roots
function misses the zero for z equal
to 0. In fact, it misses poles and zeros for z equal to 0 whenever the input transfer
function has more poles than zeros or vice versa. This is acceptable in most cases. To circumvent
the problem, however, simply append zeros to make the vectors the same length before using the
roots
function, for example, b = [b 0]
.
[z,p,k] = tf2zp([b 0],a) z = 0 -0.7500 + 1.1990i -0.7500 - 1.1990i p = -1.0000 -1.0000 + 0.0000i -1.0000 - 0.0000i k = 2
It is always possible to represent a digital filter, or a system of difference equations, as a set of first-order difference equations. In matrix or state-space form, you can write the equations as
whereu
is the input, x
is the state vector, and y
is
the output. For single-channel systems, A
is an m-by-m matrix where m
is the order of the filter, B
is a column vector, C
is a row vector, and
D
is a scalar. State-space notation is especially convenient for multichannel systems
where input u
and output y
become vectors, and B
, C
,
and D
become matrices.
Taking the z-transform of the state-space equations and combining them shows the equivalence of the state-space and transfer function form:
The Matlab signal-processing function
tf2ss
converts the transfer function to state-space form.
[A, B, C, D] = tf2ss(b,a) A = -3 -3 -1 1 0 0 0 1 0 B = 1 0 0 C = 2 3 4 D = 0
The Matlab signal-processing function
ss2tf
converts from state-space form to transfer function.
The Matlab signal-processing function
residuez
converts transfer function to partial-fraction form.
[r,p,k] = residuez(b,a) r = 4.0000 - 0.0000i -5.0001 - 0.0000i 3.0000 + 0.0000i p = -1.0000 -1.0000 - 0.0000i -1.0000 + 0.0000i k = []
Any transfer function H(z) has a second-order sections representation,
where K is the number of second-order sections that describe the system. Matlab represents the second-order section form of a discrete-time system as an K-by-6 arraysos
. Each row of sos
contains a single second-order
section, where the row elements are the three numerator and three denominator coefficients that
describe the second-order section:
There are an uncountable number of ways to represent a filter in second-order sections form.
Through careful pairing of the pole and zero pairs, ordering of hte sections in the cascade,
and multiplicative scaling of the sections, it is possible to reduce quantization noise gain
and avoid overflow in some fixed-point filter implementations.
The Matlab signal-processing functions
ss2sos
and
zp2sos
perform these operations.
sos = ss2sos(A,B,C,D) sos = 0.0061 0 0 1.0000 1.0000 0 325.9477 488.9216 651.8955 1.0000 2.0000 1.0000 sos(1,1)*sos(2,1) ans = 2
Maintained by John Loomis, last updated 14 Oct 1997