02.10.2019 Views

UploadFile_6417

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

218 Chapter 6 IMPLEMENTATION OF DISCRETE-TIME FILTERS<br />

elseif M > N<br />

a = [a zeros(1,M-N)]; N = M;<br />

else<br />

NM = 0;<br />

end<br />

%<br />

K = floor(N/2); B = zeros(K,3); A = zeros(K,3);<br />

if K*2 == N;<br />

b = [b 0]; a = [a 0];<br />

end<br />

%<br />

broots = cplxpair(roots(b)); aroots = cplxpair(roots(a));<br />

for i=1:2:2*K<br />

Brow = broots(i:1:i+1,:); Brow = real(poly(Brow));<br />

B(fix((i+1)/2),:) = Brow;<br />

Arow = aroots(i:1:i+1,:); Arow = real(poly(Arow));<br />

A(fix((i+1)/2),:) = Arow;<br />

end<br />

This function converts the b and a vectors into K × 3 B and A matrices.<br />

It begins by computing b 0 , which is equal to b 0 /a 0 (assuming a 0 ̸= 1).<br />

It then makes the vectors b and a of equal length by zero-padding the<br />

shorter vector. This ensures that each biquad has a nonzero numerator<br />

and denominator. Next it computes the roots of the B(z) and A(z) polynomials.<br />

Using the cplxpair function, these roots are ordered in complex<br />

conjugate pairs. Now every pair is converted back into a 2nd-order numerator<br />

or denominator polynomial using the poly function. The SP toolbox<br />

function, tf2sos (transfer function to 2nd-order section), also performs<br />

a similar operation.<br />

The cascade form is implemented using the following casfiltr<br />

function.<br />

function y = casfiltr(b0,B,A,x);<br />

% CASCADE form realization of IIR and FIR filters<br />

% -----------------------------------------------<br />

% y = casfiltr(b0,B,A,x);<br />

% y = output sequence<br />

% b0 = gain coefficient of CASCADE form<br />

% B = K by 3 matrix of real coefficients containing bk’s<br />

% A = K by 3 matrix of real coefficients containing ak’s<br />

% x = input sequence<br />

%<br />

[K,L] = size(B);<br />

N = length(x); w = zeros(K+1,N); w(1,:) = x;<br />

Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).<br />

Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!