PRACTICAL MATLAB® FOR ENGINEERS PRACTICAL MATLAB

(sharon) #1

588 Practical MATLAB® Applications for Engineers


continuous to the discrete domain is done, the fi lter transfer function has to be
compensated by multiplying the response by T.
For this example, the fi nal transfer function would then be the preceding expres-
sion for H(z) multiplied by T = 0.0314.
The reader can appreciate that the substitution and algebraic manipulations
involved in the transformation process just presented is labor-intensive.
This computational effort can be avoided by using the power of MATLAB as
illustrated in the following points.

R.6.107 The MATLAB function [numz, denz] = impinvar (nums, dens, fs) maps the analog
transfer function H(s) into the discrete transfer function H(z) using the substitu-
tions presented in R.6.105 and returns the numerator and denominator of H(z) =
numz/denz, given the numerator and denominator of H(s) = num(s)/den(s), with a
sampling frequency given by fs. The function impinvar used without specifying fs
takes the default value of fs = 1 Hz.


R.6.108 The MATLAB function [numz, denz] = yulewalk (n, f, mag) returns the numerator
numz and denominator denz, where H(z) = numz(z)/denz(z) as the polynomial coef-
fi cients that best fi t the points defi ned by the vectors f and mag, where n denotes
the fi lter order. f is a normalized vector specifying the set of key frequencies start-
ing at 0 and ending at 1 and mag is the corresponding vector with the desired
magnitude at the frequencies defi ned by f.


R.6.109 Unlike the transform of the analog prototype method, the yulewalk algorithm is
a direct method to design a digital fi lter based on specs in the discrete domain
with no constrains imposed by the standard fi lter prototypes. The digital fi lter
coeffi cients are evaluated by obtaining the inverse fft of the desired, ideal power
spectrum and then by solving the modifi ed Yule–Walker equations.


R.6.110 The FIR equivalent of this function is the MATLAB command fi r2, which also
returns a fi lter based on a linear piecewise magnitude approximation.


R.6.111 MATLAB’s signal processing toolbox includes a number of functions that can
directly be used in the analysis and synthesis of IIR fi lters based on the bilinear
transformation.
The bilinear transformation functions based on the standard prototype fi lters are
listed as follows:
a. [numz, denz] = butter(n, wn )
b. [z, p, k] = butter(n, wn )
c. [numz, denz] = cheby1(n, Rp, wn )
d. [z, p, k] = cheby1(n, Rp, wn )
e. [numz, denz] = cheby2(n, Rs, wn )
f. [z, p, k] = cheby2(n, Rs, wn )
g. [numz, denz] = ellip(n, Rp, Rs, wn )
h. [z, p, k] = ellip(n, Rp, Rs, wn )
where numz and denz denote the numerator and denominator coeffi cients
of H(z), Rp and Rs denote the pass- and stop-band ripples, n is the order of the
fi lter, wn is the pass-band edge; a number between 0 and 1, z denotes discrete
zeros, p denotes discrete poles, and k is the gain factor of the discrete transfer
function while the sampling frequency is assumed to be 2 Hz or a sampling rate
of T = 0.5 s.

Free download pdf