Beruflich Dokumente
Kultur Dokumente
Re
X
-/5 H(z) = k
( z 1)2 ( z .9e j / 5 )( z .9e j / 5 ) ( z 1)2 z2 (1.8 cos( / 5))z + .81
( z 1)2 z2 .9ze j / 5 .9ze j / 5 + .81
=k
=k
=k
B( z ) A( z )
Choose k so that |H()| = 1 at = /5; see MATLAB code attached. MATLAB Filter function Syntax: yy = filter(bb, aa, xx) where bb denotes the vector of coefficients for the numerator B(z) in H(z); aa denotes the vector of coefficients for the denominator A(z) in H(z); xx denotes the vector of input values; and yy denotes the vector of output values.
D. van Alphen
ECE 351
MATLAB code and graphs of the input and output follow. % program ece_351_filter % author: D. van Alphen % class: ECE 351 % this filter is supposed to block a dc signal, and pass a signal at 1 Hz, % when the time spacing is .1 sec. The H(z) was derived in ECE 351: % (H(z) = k [(z-1)^2]/(z^2 - 1.8 cos(pi/5)z + .81) t = [ 0 : .1 : 10]; % time from 0 to 10 sec s = sin(2*pi*t) + 20*ones(1,length(t)); % input sinusoid + dc omega = pi/5; % freq. to be passed z = exp(j*omega); H_num = (z - 1)^2; H_den = z ^2 -1.8*cos(pi/5)*z + .81; display('k = ') k = abs(H_den/H_num); b = k * [1 -2 1]; a = [1 -1.8*cos(pi/5) .81] f = [0 : .1 :10]; H = freqz(b, a, f, 10); % generate transfer function H(f), with fs = 10 plot(f, abs(H)) yy = filter(b, a, s); % calculates output figure subplot(2, 1, 1), plot(t, s), axis([0, 10, 0, 21]), title('Input = s(t)) % plots input subplot(2, 1, 2), plot(t, yy), title('Output = s(t) w/ dc filtered out') % plots output The code determines that k = .2931. The magnitude spectrum is:
|H(f)|
D. van Alphen
ECE 351
-5 0
4 t
10
Note that there is a transient effect evident until the system settles down. Increasing the distance 1 of the poles from zero (now set at .9; max value < 1) will improve the steady-state response, but the transients will take longer to die out. Note that this filter is doing what it was designed to do compare the output to the desired signal, sin(2t), after the transient has settled, and the system is in steadystate.
Recall that the poles must be inside the unit circle for stability.
D. van Alphen