Unformatted text preview:

73Lab 6 – IIR Filtering Experiments6.1. Transposed RealizationIn Lab-4 you implemented your own version of the function filter, specialized to FIR filters, using thetransposed realization. In this lab you will implement the IIR case. The transposed realization blockdiagram is shown in the MATLAB documentation for the function filter. An equivalent version is shownbelow for an order-3 filter.H(z)=b0+ b1z−1+ b2z−2+ b3z−31 + a1z−1+ a2z−2+ a3z−3For an Mth order filter, the computational algorithm is,y(n) = v1(n)+ b0x(n)v1(n + 1) = v2(n)+ b1x(n)−a1y(n)v2(n + 1) = v3(n)+ b2x(n)−a2y(n)...vM−1(n + 1) = vM(n)+ bM−1x(n)−aM−1y(n)vM(n + 1) = bMx(n)−aMy(n)v(n)=⎡⎢⎢⎢⎢⎣v1(n)v2(n)...vM(n)⎤⎥⎥⎥⎥⎦=state vectorThe state vector v(n) represents the current contents of the M delays. The algorithm is an exampleof a state-space realization. It computes the current outputy(n) from the current input x(n) and thecurrent state v(n) , and then, it updates the state to the next time instant, v(n + 1). Usually, the statevector is initialized to zero, but it can be initialized to an arbitrary vector, say, vin.Lab Procedurea. Write a MATLAB function, say, filtr.m, that is functionally equivalent to the built-in function filterand implements the above algorithm and has the possible syntaxes:y = filtr(b,a,x);[y,vout] = filtr(b,a,x,vin);% b = order-L numerator coefficient vector, b = [b0, b1, b2, ..., bL]% a = order-K denominator coefficient vector,a=[1,a1,a2,..., aK]% x = length-N vector of input samples (row or column)% y = length-N vector of output samples (row or column according to x)% vin = M-dimensional vector of initial states - zero vector, by default% vout = M-dimensional final state vector, i.e., final contents of delays6 IIR FILTERING EXPERIMENTS 74Internally, yout function must extend b, a to the maximum required order M = max(L, K) bypadding zeros. Test your function on the following case:b = [1, 0.6, -0.4]; % numeratora = [1, -1.3, 0.2, 0.4]; % denominatorx = [1, 1, 2, 1, 2, 2, 1, 1];y = [1, 2.9000, 5.7700, 8.3210, 10.3033, 12.2221, 11.8997, 9.7038]; % expected resultb. The function filtr can be run on a sample by sample basis to generate the successive internal statevectors, for example, using a loop such as,v = zeros(1,M); % initial state vectorfor n=1:length(x)[y(n),vout] = filtr(b,a,x(n),v); % recycled state vector vv = vout; % next stateendAdd appropriate fprintf commands before, within, and after this loop to generate the followingtable of values for the above example,nxyv1v2v3-----------------------------------------------0 1 1.0000 0.0000 0.0000 0.00001 1 2.9000 1.9000 -0.6000 -0.40002 2 5.7700 3.7700 -1.3800 -1.16003 1 8.3210 7.3210 -3.1140 -2.30804 2 10.3033 8.3033 -4.3722 -3.32845 2 12.2221 10.2221 -6.1891 -4.12136 1 11.8997 10.8997 -7.3657 -4.88887 1 9.7038 8.7038 -7.6688 -4.75998 - - 5.5462 -7.1006 -3.8815where v1,v2,v3are the internal states at each time instant.c. The effective time constant of a stable and causal IIR filter, measured in samples, may be definedin terms of the maximum pole radius as follows,neff=ln lnR,R=maxi|pi| (6.1)wherepiare the poles of the filter, and  is a small number, such as  = 10−2or  = 10−3for theso-called 40-dB or 60-dB time constants, respectively.Calculate the 40-dB time constant of the example filter of part (a), and then using your functionfiltr, evaluate and plot its impulse responsehnover the interval 0 ≤ n ≤ neff. Similarly, evaluateand plot the unit-step response over the same time interval. Note that the asymptotic value of theunit-step response (for a stable/causal filter) is given in terms of the filter coefficients byu∞=Mm=0bmMm=0amIndicate this value on your graph of the unit-step response.6 IIR FILTERING EXPERIMENTS 75d. Envelope detectors are used extensively in communication systems and in audio effects such ascompressors and expanders. A typical envelope detector is a lowpass filter acting on the absolutevalue of a signal.In this part, you will determine the envelope of the impulse responsehnthat was calulated in thepart (c). Consider the following IIR and FIR lowpass filtering operations on the signal|hn|:(IIR)henv(n) = ahenv(n − 1)+(1 − a)|hn|(FIR) henv(n) =|hn|+|hn−1|+|hn−2|+···+|hn−N+1|N(6.2)where 0<a<1andN is an integer. It can be shown that the two filters are roughly equivalent ifone makes the identificationN = floor1 + a1 − aFor a = 0.80, calculate N, and carry out the filtering operations of Eq. (6.2). Plot h(n) and henv(n)over the time interval 0 ≤ n ≤ nneff. Make different plots for the IIR and the FIR envelopes.Repeat fora = 0.94. Comment on the tradeoffs between the two choices a = 0.80 and a = 0.94 interms of their initial transients and their ability to extract the envelope.6.2. Feedback SystemA general feedback system is shown below, where the output of filter H1(z) is fed back into filter H2(z)and then back to the input, and where the delay z−1can be positioned at the four locations A, B, C, or D.Lab Procedurea. For each case A,B,C,D, determine the transfer functionH(z) of the overall closed-loop system fromx(n) to y(n), expressed in terms of the transfer functions H1(z) and H2(z).b. Choose the forward and feedback transfer functions as,H1(z)=1 + z−11 − 0.5z−1,H2(z)=0.4 − 0.4z−11 − 0.4z−1(6.3)Show that for case A, the transfer functionH(z) is,H(z)=1 + 0.6z−1− 0.4z−21 − 1.3z−1+ 0.2z−2+ 0.4z−3(6.4)What are the transfer functionsH(z) for the cases B, C, D?c. The objective of this part is to use the function filtr on a sample-by-sample basis, applied separatelyon the transfer functionsH1(z) and H2(z), to implement the feedback system directly, withouttransforming it first into the equivalent transfer functionH(z).As we saw earlier, the filtering function filtr can be invoked repetitively on a sample-by-samplebasis using a for-loop that recycles the state vector:6 IIR FILTERING EXPERIMENTS 76s = zeros(1,M); % initial state vectorfor n=1:length(x)[y(n),s] = filtr(b,a,x(n),s); % recycled state vector sendTo implement the transfer functions H1(z) and H2(z) of part (b), you need to define their filtercoefficients and states,{b1, a1, s1} and {b2, a2, s2}, and initialize the states to zero, as well as thecontent of the delay at locations A,B,C,D. For example, initially the contentw of the delay at Ashown in the above block diagram will be zero. As an example, the pseudo-code implementationof case A


View Full Document

Rutgers University ECE 348 - Filtering Experiments

Documents in this Course
Load more
Download Filtering Experiments
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Filtering Experiments and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Filtering Experiments 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?