Problem Set 9 Solutions EE23: Digital Signal Processing. From Figure below, we see that the DTFT of the windowed sequence approaches the actual DTFT as the window size increases. Gibb s phenomenon is absent for large enough L, since the sequence a n decays exponentially. The MATLAB code is also included below. Grading: A lot of answers write that Gibbs phenomenon is present. This is incorrect. Subtract /2 point for this mistake. Most of these answers had guesses about what is Gibbs phenomenon. I will suggest that read Gibbs phenomenon from the Wikipedia link to understand it better. 2 2 H 32 (ω) H 64 (ω) 2 2 2 2 ω 2 2 ω 2 2 H 28 (ω) 2 H 256 (ω) 2 2 2 ω 2 2 ω Figure : Analysis Circuit hw9p3.m: a =.977; You can show this formally by showing that H(e jω ) H N (e jω ) = P n>n an e jωn as N, for all ω. Note that the for all ω clause is very important.
N = 24; print_to_file = yes ; L = 32; n_32 = :32; x_32 = a.^(n_32-); [H_32,W] = dtft(x_32,n); L = 64; n_64 = :64; x_64 = a.^(n_64-); [H_64,W] = dtft(x_64,n); L = 28; n_28 = :28; x_28 = a.^(n_28-); [H_28,W] = dtft(x_28,n); L = 256; n_256 = :256; x_256 = a.^(n_256-); [H_256,W] = dtft(x_256,n); X =./(-a*exp(i*w)); figure() subplot(22) semilogy(w,abs(h_32), b,w,abs(x), r-- ); axis([-pi pi ^-3 ]); xlabel( \omega ---\rightarrow ); ylabel( H_{32}(\omega) ---\rightarrow ); subplot(222) semilogy(w,abs(h_64), b,w,abs(x), r-- ); axis([-pi pi ^-3 ]); xlabel( \omega ---\rightarrow ); ylabel( H_{64}(\omega) ---\rightarrow ); subplot(223) semilogy(w,abs(h_28), b,w,abs(x), r-- ); axis([-pi pi ^-3 ]); xlabel( \omega ---\rightarrow ); ylabel( H_{28}(\omega) ---\rightarrow ); 2
subplot(224) semilogy(w,abs(h_256), b,w,abs(x), r-- ); axis([-pi pi ^-3 ]); xlabel( \omega ---\rightarrow ); ylabel( H_{256}(\omega) ---\rightarrow ); if (print_to_file == yes ) print -depsc prob_4_.eps; end dtft.m: function [X,W]=dtft(x,N) %dtft X=fftshift(fft(x,N)); W=[-N/2:N/2-]*2*pi/N; return 2. 3
Correction: H lpf (e jω ) = 2, ω π/4. Do not deduct any point if you got the π/4 cut-off correct, but deduct half-point if you got the cut-off incorrect. This error ripples in Solution to part (c). 4
3. (b).4 #4b.: Magnitude response of the length 36 FIR BPF.8 #4b.2: Close up of magnitude response of the length 36 FIR BPF.2.6.4.2.8.6.998.4.996.2.994.5.5 2 2.5 3 Discrete angular frequency, lambda (rad/s) #4b.3: Log magnitude response of the length 36 FIR BPF.992..2.3.4.5.6.7.8.9 2 2. Discrete angular frequency, lambda (rad/s) #4b.4: Phase response of the length 36 FIR BPF 4 3 2 Log magnitude 2 3 4 Phase response (rad) 2 5 3 6.5.5 2 2.5 3 Discrete angular frequency, lambda (rad/s) 4.5.5 2 2.5 3 Discrete angular frequency, lambda (rad/s) i. Maximum passband ripple amplitude (in db relative to.) is 2 log(.4/) =.35 db. Worst-case stopband attentuation is 2 log(4 3 ) = -48. db. Defining the transition bandwidth as the region of the response which fails to satisfy these two criteria, it is roughly 2.65 2.7 =.58 rad/s for the last edge. The transition bandwidth at the first edge is essentially the same (.8.5 =.58). Taking the position of the band edge to be the average of the edges of the passband and stopband gives ω c = (2.65 + 2.7)/2 = 2.36 rad/s, ω c2 = (.8 +.5)/2 =.79 rad/s, which are both less than half a percent from the design values. ii. The total number of zeros is N = 35, because the transfer function is simply a polynomial of degree N in z which has at most that many roots. To count zeros on the unit circle, refer to the log magnitude plot. Each of the downward spikes is a point where the response goes to zero, corresponding to a zero that we are passing through on the unit circle (recall that the DTFT is simply the z-transform evaluated around the unit circle. Each of these should be counted twice, except at ω = or π, because the zeros occur in conjugate pairs (because the transfer function polynomial has real coefficients) and we are only seeing the zeros in positive frequency. Thus, there are zeros on the unit circle. The Matlab command zplane(a,) can be 5
used to verify these answers. It produces the plot given below. #4b.extra: z plane pole/zero plot for the length 36 FIR BPF.5.5 Imaginary part.5.5.5.5.5.5 2 Real part iii. There is a pole of multiplicity 35 at the origin. iv. The slope of the phase is M = (N )/2 = 35/2 due to the known results for generalized linear phase filters. The jumps of 2π are not really jumps at all since the phase is increasing or decreasing linearly there; they appear as jumps because we insist on referring the phase to a range of principal angles from π to π. The jumps of π occur only in the stopband and correspond to the frequencies where the real part of the DTFT, R(e jω ), crosses zero and changes sign. This comes from Euler s identity, = e jπ. 4. (a) From a close examination of the frequency response, ω p 2.2 and ω s.58. The ripple amplitudes are δ p. and δ s.57. Since Q s Q p = δ p δ s, the ratio Q s /Q p.75, and any pair of weights Q s and Q p having that ratio may have been used. (b) The filter is of odd length. Which type of generalized linear phase does it have? By the constraints on realizable filter types, we see that the filter must have even symmetry (Type I GLP) because otherwise we could not have H d (e j ) >. Also, H d (e j ) > implies that the phase at ω = must be zero with a slope equal to M = (N )/2 = 5. The only remaining trick is to figure out where R(ω) changes sign, because the phase plot will need jumps of π at those points. For this, refer to the frequency response plot and note that wherever the magnitude goes to zero, there must have been a zero-crossing (and hence sign change) of R(ω). 6
Missing phase plot 3 2 Phase response (rad) 2 3.5.5 2 2.5 3 ω (rad/s) 5. The following code would solve the problem. The main idea is to start with a small n (filter order), and increase the filter order till the target δ. is achieved. f = [.6.32.67.83 ]; m = [ ]; w = [ ]; n = 3; delta =. while (delta >.) [a, delta] = firpm(n,f,m,w); n = n + ; end n = n -; % correcting for extra increase in n plot((::n-), real(a(:n)), o-- ); grid on; xlabel( k ); ylabel( h[k] ); title( Impulse response of length-27 BP filter ); The final answer is N = 27. The impulse response of h 27 [n] is plotted below: 7
.4 Impulse response of length 27 BP filter.3.2. h[k]..2.3 5 5 2 25 3 k 6. See next page. 8
(a) Low-pass filter using Windowing i. The mid-point of transition band is used as LPF cutoff, ω c =.45π. The impulse response, magnitude response and zero locations of the three windowing filters is shown in Figure. ii. For the same minimax error, the transition band is largest for the Blackman window and smallest for the Rectangular window. The smoother windows tradeoff the transition band for smoothness and absence of Gibbs phenomenon. iii. The minimax is calculated using the expression max( (abs(h) H d ) ). I ve used 24 points in the freqz() command to calculate the errors. Give yourself full credit if your answer is 25% within my answer. Report any numerical error to Animesh. FILTER MSE Delta_P Delta_s Rectangular.95.59.97 Hamming.7.2459.2439 Blackman.222.2982.2985 (b) Low-pass filter using Parks McClellan Optimal Filter i. The filter s impulse response, frequency response, and zero locations is shown in Figure 2. ii. There are 5 ripples in the passband and 6 ripples in the stopband. This amounts to a total of ripples including extrema at ω p, ω s, and at ω = π. iii. Total of small ripple at ω = and it is in the passband. iv. The minimax error the Parks-McClellan Filter is:.56. From the diagram (and question design itself), note that the transition bandwidth for the Parks-McClellan filter is.4π -.5π. Clearly, the transition bandwidth is at par with the performance of the rectangular filter and outperforms Hamming and Blackman Filters. Moreover, Parks-McClellan filter s maximum delta value in the passband and stopband is.55. This filter outperforms the rectangular filter whose max delta value is.97.
FIGURE Rectangular.4.2 h[n] 2 Magnitude (db) -5 H(ω) - - Imaginary Part.5 -.5 - Zero Locations of FIR filters 2 - Hamming Blackman.4.2.4.2 2 2 n Magnitude (db) Magnitude (db) -5 - - -5 - - ω (xπ rad/sample) Imaginary Part Imaginary Part 2 - - 2 x 4 2 2 - -2-4 -2 Real Part x 4
FIGURE 2 Parks-McClellan Optimal 2-tap FIR Filter Zeros of the FIR Filter.4 Filter coefficients.3.2. Imaginary Part.5 -.5 2 -. 5 5 2 n ----> - - -.5.5.5 Real Part Magnitude of the Frequency Response Phase of the Frequency Response.8-5 H(ω).6.4.2 Phase( H(ω) ) - -5 2 3 ω (radians) -2 2 3 4 ω (radians)