Digital Signal Processing Using MATLAB

March 26, 2018 | Author: 오유택 | Category: Pi, Digital Signal Processing, Complex Analysis, Analysis, Physics & Mathematics


Comments



Description

Solutions Manualfor Digital Signal Processing using Matlab - Second Edition ©Vinay K. Ingle 2007 2 Solutions Manual for DSP using Matlab (2nd Edition) 2006 Chapter 2 Discrete-Time Signals and Systems P2.1 Generate the following sequences using the basic Matlab signal functions and the basic Matlab signal operations discussed in this chapter. Plot signal samples using the stem function. 1. x1 (n) = 3δ(n + 2) + 2δ(n) − δ(n − 3) + 5δ(n − 7), −5 ≤ n ≤ 15 % P0201a: x1(n) = 3*delta(n + 2) + 2*delta(n) - delta(n - 3) + % 5*delta(n - 7), -5 <= n <= 15. clc; close all; x1 = 3*impseq(-2,-5,15) + 2*impseq(0,-5,15) - impseq(3,-5,15) ... + 5*impseq(7,-5,15); Hf_1 = figure; set(Hf_1,’NumberTitle’,’off’,’Name’,’P0201a’); n1 = [-5:15]; Hs = stem(n1,x1,’filled’); set(Hs,’markersize’,2); axis([min(n1)-1,max(n1)+1,min(x1)-1,max(x1)+1]); xlabel(’n’,’FontSize’,LFS); ylabel(’x_1(n)’,’FontSize’,LFS); title(’Sequence x_1(n)’,’FontSize’,TFS); set(gca,’XTickMode’,’manual’,’XTick’,n1,’FontSize’,8); print -deps2 ../EPSFILES/P0201a; The plots of x1 (n) is shown in Figure 2.1. 3 Solutions Manual for DSP using Matlab (2nd Edition) Sequence x1(n) 6 5 4 3 x1(n) 4 2 1 0 −1 −2 −5 −4 −3 −2 −1 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 n Figure 2.1: Problem P2.1.1 sequence plot 2006 2006 Solutions Manual for DSP using Matlab (2nd Edition) 2. x2 (n) = 5 X k=−5 e−|k| δ(n − 2k), −10 ≤ n ≤ 10. % P0201b: x2(n) = sum_{k = -5}^{5} e^{-|k|}*delta(n - 2k), -10 <= n <= 10 clc; close all; n2 = [-10:10]; x2 = zeros(1,length(n2)); for k = -5:5 x2 = x2 + exp(-abs(k))*impseq(2*k ,-10,10); end Hf_1 = figure; set(Hf_1,’NumberTitle’,’off’,’Name’,’P0201b’); Hs = stem(n2,x2,’filled’); set(Hs,’markersize’,2); axis([min(n2)-1,max(n2)+1,min(x2)-1,max(x2)+1]); xlabel(’n’,’FontSize’,LFS); ylabel(’x_2(n)’,’FontSize’,LFS); title(’Sequence x_2(n)’,’FontSize’,TFS); set(gca,’XTickMode’,’manual’,’XTick’,n2); print -deps2 ../EPSFILES/P0201b; The plots of x2 (n) is shown in Figure 2.2. Sequence x (n) 2 2 1.5 x2(n) 1 0.5 0 −0.5 −1 −10 −9 −8 −7 −6 −5 −4 −3 −2 −1 0 1 2 3 4 5 n Figure 2.2: Problem P2.1.2 sequence plot 6 7 8 9 10 5 Solutions Manual for DSP using Matlab (2nd Edition) 3. x3 (n) = 10u(n) − 5u(n − 5) − 10u(n − 10) + 5u(n − 15). % P0201c: x3(n) = 10u(n) - 5u(n - 5) + 10u(n - 10) + 5u(n - 15). clc; close all; x3 = 10*stepseq(0,0,20) - 5*stepseq(5,0,20) - 10*stepseq(10,0,20) ... + 5*stepseq(15,0,20); n3 = [0:20]; Hf_1 = figure; set(Hf_1,’NumberTitle’,’off’,’Name’,’P0201c’); Hs = stem(n3,x3,’filled’); set(Hs,’markersize’,2); axis([min(n3)-1,max(n3)+1,min(x3)-1,max(x3)+2]); ytick = [-6:2:12]; xlabel(’n’,’FontSize’,LFS); ylabel(’x_3(n)’,’FontSize’,LFS); title(’Sequence x_3(n)’,’FontSize’,TFS); set(gca,’XTickMode’,’manual’,’XTick’,n3); set(gca,’YTickMode’,’manual’,’YTick’,ytick); print -deps2 ../EPSFILES/P0201c; The plots of x3 (n) is shown in Figure 2.3. Sequence x3(n) 12 10 8 6 x3(n) 6 4 2 0 −2 −4 −6 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 n Figure 2.3: Problem P2.1.3 sequence plot 2006 2006 Solutions Manual for DSP using Matlab (2nd Edition) 4. x4 (n) = e0.1n [u(n + 20) − u(n − 10)]. % P0201d: x4(n) = e ^ {0.1n} [u(n + 20) - u(n - 10)]. clc; close all; n4 = [-25:15]; x4 = exp(0.1*n4).*(stepseq(-20,-25,15) - stepseq(10,-25,15)); Hf_1 = figure; set(Hf_1,’NumberTitle’,’off’,’Name’,’P0201d’); Hs = stem(n4,x4,’filled’); set(Hs,’markersize’,2); axis([min(n4)-2,max(n4)+2,min(x4)-1,max(x4)+1]); xlabel(’n’,’FontSize’,LFS); ylabel(’x_4(n)’,’FontSize’,LFS); title(’Sequence x_4(n)’,’FontSize’,TFS); ntick = [n4(1):5:n4(end)]; set(gca,’XTickMode’,’manual’,’XTick’,ntick); print -deps2 ../CHAP2_EPSFILES/P0201d; print -deps2 ../../Latex/P0201d; The plots of x4 (n) is shown in Figure 2.4. Sequence x4(n) 3 2.5 x4(n) 2 1.5 1 0.5 0 −0.5 −1 −25 −20 −15 −10 −5 0 5 n Figure 2.4: Problem P2.1.4 sequence plot 10 15 7 49π n) + cos(0.ytick).’markersize’.’P0201e’).49*pi*n) + cos(0. % P0201e: x5(n) = 5[cos(0. set(Hs. print -deps2 .max(x5)+2]). close all.TFS).’Name’. The plots of x5 (n) is shown in Figure 2. Hs = stem(n5. ntick = [n5(1): 40:n5(end)]. set(Hf_1. ytick = [-12 -10:5:10 12]. xlabel(’n’.’filled’).LFS). title(’Sequence x_5(n)’.5 sequence plot 160 200 ./. print -deps2 . ylabel(’x_5(n)’. Comment on the waveform shape. axis([min(n5)-10. clc..’YTickMode’. Sequence x5(n) 12 10 5 x5(n) 8 0 −5 −10 −12 −200 −160 −120 −80 −40 0 40 80 120 n Figure 2..’off’. set(gca. −200 ≤ n ≤ 200. set(gca. n5 = [-200:200].1.49*pi*n5) + cos(0.’YTick’.’FontSize’.’manual’.’manual’./Latex/P0201e.’XTick’.5.5: Problem P2.ntick).x5.’FOntSize’.min(x5)-2.51*pi*n5)). Hf_1 = figure./CHAP2_EPSFILES/P0201e.2). -200 <= n <= 200.’FontSize’. x5 = 5*(cos(0.Solutions Manual for DSP using Matlab (2nd Edition) 2006 5.’NumberTitle’. x5 (n) = 5[cos(0.max(n5)+10.51*pi*n)].’XTickMode’..LFS).51π n)]. max(n6)+10.TFS).LFS).max(x6)+1]).6: Problem P2. set(Hs.01*pi*n6).01π n) cos(0.x6..’XTickMode’. ylabel(’x_6(n)’. x6 = 2*sin(0.5π n). clc. x6 (n) = 2 sin(0.1..’FontSize’.’filled’). xlabel(’n’. %P0201f: x6(n) = 2 sin(0. title(’Sequence x_6(n)’.LFS). Hf_1 = figure.2006 Solutions Manual for DSP using Matlab (2nd Edition) 6. −200 ≤ n ≤ 200. set(Hf_1. close all. The plots of x6 (n) is shown in Figure 2. set(gca.5*pi*n)..’manual’.’Name’.’off’./.5*pi*n6). ntick = [n6(1): 40:n6(end)].’XTick’. -200 <= n <= 200.’P0201f’). Sequence x6(n) 3 2 x6(n) 1 0 −1 −2 −3 −200 −160 −120 −80 −40 0 40 80 120 n Figure 2.6 sequence plot 160 200 9 .’FontSize’. Hs = stem(n6./Latex/P0201f.ntick).min(x6)-1./CHAP2_EPSFILES/P0201f.’NumberTitle’. n6 = [-200:200]. axis([min(n6)-10. print -deps2 .01*pi*n) cos(0.*cos(0.6.’markersize’.’FontSize’. print -deps2 .2). 7: Problem P2.’off’. set(gca.05n sin(0. x7 (n) = e−0.’FontSize’.5 −1 −1. 0 <= n <=100.max(n7)+5.05*n7).7. n7 = [0:100]. axis([min(n7)-5.’P0201g’). Hs = stem(n7.min(x7)-1.1π n + π/3).’filled’)./CHAP2_EPSFILES/P0201g.05*n}*sin(0.1.5 x7(n) 1 0. 0 ≤ n ≤ 100. x7 = exp(-0.Solutions Manual for DSP using Matlab (2nd Edition) 10 2006 7.’NumberTitle’.2).1*pi*n7 + pi/3). print -deps2 .7 sequence plot 90 100 . xlabel(’n’.max(x7)+1]). close all. ntick = [n7(1): 10:n7(end)].. Sequence x (n) 7 1.5 0 −0.ntick).LFS). clc. The plots of x7 (n) is shown in Figure 2.’FontSize’. title(’Sequence x_7(n)’.x7.TFS). set(Hf_1. Hf_1 = figure.’markersize’. ylabel(’x_7(n)’.1*pi*n + pi/3).’manual’.’FontSize’.LFS).’XTickMode’. set(Hs.’Name’. % P0201g: x7(n) = e ^ {-0.’XTick’.5 0 10 20 30 40 50 60 70 80 n Figure 2.*sin(0. ylabel(’x_8(n)’. close all.LFS). 0 <= n <=100. set(Hs.01*n8).’markersize’.min(x8)-1.1.’FontSize’. Hs = stem(n8.1*pi*n8). set(Hf_1.ntick).’XTick’. Sequence x (n) 8 3 2 x8(n) 1 0 −1 −2 −3 0 10 20 30 40 50 60 70 80 n Figure 2. set(gca.’off’.’Name’.LFS). axis([min(n8)-5. print -deps2 . % P0201h: x8(n) = e ^ {0. x8 = exp(0.TFS).’manual’.*sin(0.2). ntick = [n8(1): 10:n8(end)].max(x8)+1]).’filled’).1π n). title(’Sequence x_8(n)’. Hf_1 = figure.’FontSize’.x8..’NumberTitle’.max(n8)+5. x8 (n) = e0.’XTickMode’.8: Problem P2.8 sequence plot 90 100 11 .1*pi*n). xlabel(’n’. n8 = [0:100].01n sin(0.01*n}*sin(0.2006 Solutions Manual for DSP using Matlab (2nd Edition) 8.’P0201h’)./CHAP2_EPSFILES/P0201h The plots of x8 (n) is shown in Figure 2. 0 ≤ n ≤ 100. clc.’FontSize’.8. 9: Problem P2.TFS). ylabel(’number of elements’.’FontSize’. 2] interval.1 0 1200]).’off’. h1).2 0. [h1. % P0202a: x1(n) = uniform[0. title(’Histogram of sequence x_1(n) in 100 bins’.4 0. x1 (n) is a random sequence whose samples are independent and uniformly distributed over [0.1 2. axis([-0.2.x1out] = hist(x1. close all. Hf_1 = figure.’NumberTitle’.100000).1 sequence plot 1.Solutions Manual for DSP using Matlab (2nd Edition) 12 2006 P2.6 interval Figure 2.2] clc.6 0.8 2 .9./CHAP2_EPSFILES/P0202a.100).’FontSize’. n1 = [0:100000-1]. Generate 100. The plots of x1 (n) is shown in Figure 2.000 samples.2 1.LFS). set(Hf_1. xlabel(’interval’. x1 = 2*rand(1. Histogram of sequence x1(n) in 100 bins 1200 number of elements 1000 800 600 400 200 0 0 0. 1..2 Generate the following random sequences and obtain their histogram using the hist function with 100 bins.’Name’.LFS). bar(x1out.4 1. Use the bar function to plot each histogram.’P0202a’). print -deps2 .’FontSize’.8 1 1. x2 = 10 + sqrt(10)*randn(1. % P0202b: x2(n) = gaussian{10. title(’Histogram of sequence x_2(n) in 100 bins’. close all.’off’.’P0202b’). [h2. set(Hf_1. x2 (n) is a Gaussian random sequence whose samples are independent with mean 10 and variance 10.’Name’.100). n2 = [1:10000].x2out] = hist(x2.10} clc. print -deps2 .2 sequence plot 20 25 . Generate 10..LFS). bar(x2out.10000).2006 Solutions Manual for DSP using Matlab (2nd Edition) 13 2. Histogram of sequence x (n) in 100 bins 2 400 number of elements 350 300 250 200 150 100 50 0 −5 0 5 10 15 interval Figure 2.’FontSize’./CHAP2_EPSFILES/P0202b.LFS).h2).000 samples. The plots of x2 (n) is shown in Figure 2.10: Problem P2. xlabel(’interval’. ylabel(’number of elements’.’FontSize’.’NumberTitle’.’FontSize’. Hf_1 = figure.TFS).10.2. The plots of x3 (n) is shown in Figure 2.n3] = sigadd(x1. x3 (n) = x1 (n) + x1 (n − 1) where x1 (n) is the random sequence given in part 1 above.100).’NumberTitle’.2. Histogram of sequence x3(n) in 100 bins number of elements 2500 2000 1500 1000 500 0 −0./CHAP2_EPSFILES/P0202c.100000).’off’.n11] = sigshift(x1.’FontSize’. x1(n) = uniform[0.11. print -deps2 .Solutions Manual for DSP using Matlab (2nd Edition) 14 2006 3.’P0202c’).1) where clc.5 1 1.5 0 0.’Name’. [x11.1).LFS).5 .5 interval Figure 2.5 4.n1.5 2 2.5 0 2500]).LFS). [x3.3 sequence plot 4 4.h3). % P0202c: x3(n) = x1(n) + x1(n .’FontSize’.n11). axis([-0. xlabel(’interval’. x1 = 2*rand(1. ylabel(’number of elements’. Hf_1 = figure.TFS).x3out] = hist(x3.11: Problem P2. Comment on the shape of this histogram and explain the shape. set(Hf_1. title(’Histogram of sequence x_3(n) in 100 bins’.2] n1 = [0:100000-1].n1. close all.5 3 3. bar(x3out.x11. [h3..’FontSize’. Histogram of sequence x4(n) in 100 bins 3000 number of elements 2500 2000 1500 1000 500 0 −2 −1.100000) .0.100).5 1 interval Figure 2.’FontSize’.5.5 −1 −0. Comment on the shape of this histogram.100000) .0. x4 (n) = 4k=1 yk (n) where each random sequence yk (n) is independent of others with samples uniformly distributed over [−0.0.LFS).’P0202d’).LFS). y2 = rand(1./CHAP2_EPSFILES/P0202d. where each independent of others % with samples uniformly distributed over [-0. y1 = rand(1.’NumberTitle’. set(Hf_1. print -deps2 . [h4. 0. y4 = rand(1.5.5.5].100000) . x4 = y1 + y2 + y3 + y4. Hf_1 = figure.5 2 .5. y3 = rand(1.12: Problem P2. ylabel(’number of elements’. xlabel(’interval’.0.5].12.TFS).0.. bar(x4out.5.5 0 0.’Name’.’FontSize’.’FontSize’.5. close all.x4out] = hist(x4.4 sequence plot 1. clc.100000) . %P0202d: x4(n) = sum_{k=1} ^ {4} y_k(n).’off’.2006 Solutions Manual for DSP using Matlab (2nd Edition) 15 P 4. title(’Histogram of sequence x_4(n) in 100 bins’. The plots of x4 (n) is shown in Figure 2.2.h4). . close all. . . 1. Hs = stem(n1..-2. x1 = [-2.-1.16 Solutions Manual for DSP using Matlab (2nd Edition) 2006 P2. Sequence x1(n) 3 2 x1(n) 1 0 −1 −2 −3 −12 −10 −8 −6 −4 −2 0 2 4 6 n Figure 2.’FontSize’.LFS). axis([min(n1)-1.’NumberTitle’..0. ↑ % P0203a: x1(n) = {.’markersize’. 2.min(x1)-1.13: Problem P2.ytick).’XTick’.1.. −1.max(n1)+1. x1 = (x1(:))’.}periodic. set(Hs.’manual’.’off’.5).max(x1)+1]).’XTickMode’. −2. print -deps2 . ylabel(’x_1(n)’. ntick = [n1(1):2:n1(end)].’manual’. 0.-2. Hf_1 = figure.0.’P0203a’).x1.-1.-1.’Name’.1.ntick). 5 periods clc. set(Hf_1.2).0. . set(gca. n1 = [-12:12].. x1 = x1’*ones(1.2.’YTick’. title(’Sequence x_1(n)’.2. ytick = [min(x1) ..13. .2].’YTickMode’.} periodic. 1.1:max(x1) + 1]. .’filled’).TFS).1 sequence plot 8 10 12 .’FontSize’. .3 Generate the following periodic sequences and plot their samples (using the stem function) over the indicated number of periods.1. x˜1 (n) = {.LFS). Plot 5 periods. set(gca.3./CHAP2_EPSFILES/P0203a The plots of x˜1 (n) is shown in Figure 2.’FontSize’. xlabel(’n’. 0. set(gca. 3 periods clc.’markersize’.’FontSize’.*(stepseq(0. Hs = stem(n2. x2 = (x2(:))’.1*n2). ylabel(’x_2(n)’. n2 = [-22:43].LFS). n2 = [0:21]. Hf_1 = figure.2006 Solutions Manual for DSP using Matlab (2nd Edition) 2.TFS).3. The plots of x˜2 (n) is shown in Figure 2.’NumberTitle’. set(Hs. print -deps2 . set(Hf_1. % P0203b: x2 = e ^ {0. x2 = x2’*ones(1.’FontSize’. title(’Sequence x_2(n)’.min(x2)-1.14: Problem P2.x2.’FontSize’.3). x2 = exp(0.’XTick’.’XTickMode’. Sequence x2(n) 7 6 x2(n) 5 4 3 2 1 0 −1 −22 −18 −14 −10 −6 −2 2 6 10 14 18 22 26 30 34 38 n Figure 2. x˜2 (n) = e0.14.’manual’.’off’.2).1n [u(n) − u(n − 20]periodic .max(n2)+4./Chap2_EPSFILES/P0203b. Plot 3 periods.ntick).’P0203b’).’Name’.u(n-20)] periodic.2 sequence plot 43 17 .0.LFS). xlabel(’n’. ntick = [n2(1):4:n2(end)-5 n2(end)].21)-stepseq(20.’filled’).1n} [u(n) .. axis([min(n2)-2.max(x2)+1]).21)). close all. 2.1*pi*n3).1.4). % P0203c: x1(n) = {.} periodic. Hf_1 = figure..*(stepseq(0.5 0 −0.15.’FontSize’. set(Hf_1.TFS).5 x3(n) 1 0... x3 = (x3(:))’. title(’Sequence x_3(n)’.’off’. Sequence x3(n) 1.-2.’markersize’. close all.3 sequence plot 28 32 35 .5.max(n3)+1.’XTickMode’.5]). x3 = sin(0.1π n)[u(n) − u(n − 10)]./CHAP2_EPSFILES/P0203c. The plots of x˜3 (n) is shown in Figure 2.LFS).Solutions Manual for DSP using Matlab (2nd Edition) 18 2006 3.2).’FontSize’. set(gca.-1.’FontSize’. set(Hs.’filled’). Hs = stem(n3.’Name’.0.0.. Plot 4 periods.x3. n3 = [0:11].-2.’XTick’.’manual’.11)-stepseq(10. axis([min(n3)-1.0..15: Problem P2.1. x3 = x3’*ones(1.ntick). xlabel(’n’.LFS). ntick = [n3(1):4:n3(end)-3 n3(end)].0.’P0203c’).-1. ylabel(’x_3(n)’. x˜3 (n) = sin(0.11)).min(x3)-0.max(x3)+0.5 −12 −8 −4 0 4 8 12 16 20 24 n Figure 2.2.. n3 = [-12:35]. print -deps2 .3. 5 periods clc.’NumberTitle’. }periodic. What is the period of x˜4 (n)? ↑ ↑ % P0203d x1(n) = {. axis([min(n4)-1. LFS).’NumberTitle’. ’FontSize’.’Name’.’XTickMode’.’off’. . 3. From the figure.-2.-1.’P0203d’).0..’manual’. ntick = [n4(1) :2:n4(end)]. 1.2006 Solutions Manual for DSP using Matlab (2nd Edition) 19 4.min(x4)-1.max(n4)+1.2. set(Hs. 2.-2.2.} periodic..2). Sequence x (n) : Period = 12 4 8 7 x4(n) 6 5 4 3 2 1 0 2 4 6 8 10 12 14 16 18 n Figure 2. . 0 ≤ n ≤ 24.16. .}periodic + {. x4a = [1 2 3]. x4b = [1 2 3 4]. set(Hf_1.3. n4 = [0:24]..’filled’).ntick). 5 periods clc.’FontSize’. x4b = (x4b(:))’. 4. .. . x4 = x4a(1:25) + x4b(1:25). title(’Sequence x_4(n):Period = 12’. x4a = x4a’*ones(1.16: Problem P2.’XTick’. x˜4 (n) = {. ylabel(’x_4(n)’.. x4b = x4b’*ones(1.max(x4)+1]).-1.1. The plots of x˜4 (n) is shown in Figure 2. Hs = stem(n4. .4 sequence plot 20 22 24 .x4. . . print -deps2 . . . set(gca.LFS).’markersize’. 1. Hf_1 = figure./CHAP2_EPSFILES/P0203d.7). .TFS). . 2.0..’FontSize’. the fundamental period of x˜4 (n) is 12. xlabel(’n’.1. 3.9). close all. x4a = (x4a(:))’. 7}. The plots of x1 (n) is shown in Figure 2.4. print -deps2 .’manual’.-3. axis([min(n1)-1. xlabel(’n’. 4.7].’YTick’.’FontSize’. ylabel(’x_1(n)’. Hs = stem(n1. set(gca. % add % shift by 3 % shift by -4 sequences two sequences Hf_1 = figure..4 Let x(n) = {2. −3.-5.n12).-3./CHAP2_EPSFILES/P0204a.n13] = sigadd(2*x11.’manual’. -3 <=n <= 3.min(x1)-3.x(n) clc.3*x12.’off’.Solutions Manual for DSP using Matlab (2nd Edition) 20 2006 P2.n1] = sigadd(x13.’XTick’. 4. set(gca. ytick = [min(x1)-3:5:max(x1)+1]. −5.’markersize’.’YTickMode’. close all.17: Problem P2.n12] = sigshift(x. % add two [x1.-5.7].’filled’). 1.2).ytick).’P0204a’). n = [-3:3].n13.3) + 3x(n + 4) .n. [x11.4.1.4. x1 (n) = 2x(n − 3) + 3x(n + 4) − x(n) % P0204a: x(n) = [2.1 sequence plot 4 5 6 .’XTickMode’. title(’Sequence x_1(n)’.-x.3).TFS). ntick = n1.4.n).’Name’. [x13.17.4.1.max(n1)+1.’FontSize’.LFS).’NumberTitle’. [x12.’FontSize’. set(Hs. 1. Generate and plot the samples (use the stem function) of the following ↑ sequences.n11] = sigshift(x. set(Hf_1. x = [2.-4). % x1(n) = 2x(n .max(x1)+1]).x1.n11.n. Sequence x1(n) 25 20 15 x1(n) 10 5 0 −5 −10 −15 −20 −7 −6 −5 −4 −3 −2 −1 0 1 2 3 n Figure 2.ntick).LFS). % add two sequences sigadd(x23. ytick = [-25 -20:10:60 65]. set(gca.-5.n21.ntick).1.n22).-3.7].n. % add two sequences Hs = stem(n2.’manual’.’filled’).TFS).5*x22.’YTickMode’. % shift by -5 = sigadd(4*x21.’FontSize’. % x2(n) = 4x(4 + n) + 5x(n + 5) + 2x(n) clc.x2. The plots of x2 (n) is shown in Figure 2.n22] [x23.’P0204b’)..’FontSize’. set(gca.’XTick’.LFS).n23] [x2. Sequence x2(n) 65 60 50 40 x2(n) 30 20 10 0 −10 −20 −25 −8 −7 −6 −5 −4 −3 −2 −1 0 1 n Figure 2. ntick = n2.18.max(n2)+1.LFS).4. title(’Sequence x_2(n)’. x = [2. xlabel(’n’.’off’.min(x2)-4.’markersize’. set(Hs.18: Problem P2.n23.’NumberTitle’.2006 Solutions Manual for DSP using Matlab (2nd Edition) 2./CHAP2_EPSFILES/P0204b.’XTickMode’.4.1. n = [-3:3].n2] = = sigshift(x.n).max(x2)+6]).7].n. ylabel(’x_2(n)’. [x21.4. close all. print -deps2 .’Name’. set(Hf_1. % shift by -4 = sigshift(x.-4).’manual’.’FontSize’.2 sequence plot 2 3 21 .4.-3.n21] [x22.-5.2). Hf_1 = figure.ytick).2*x.-5). axis([min(n2)-1.’YTick’.4. -3 <=n <= 3. x2 (n) = 4x(4 + n) + 5x(n + 5) + 2x(n) % P0204b: x(n) = [2. n31] = [x32.Solutions Manual for DSP using Matlab (2nd Edition) 2006 3. title(’Sequence x_3(n)’.x32. -3 <=n <= 3.TFS).7]. % add 2 sequences Hf_1 = figure.19.’FontSize’.n35). % multiply 2 sequences sigadd(x33.LFS).’FontSize’. % shift sequence by -3 sigshift(x.’FontSize’. set(Hf_1.4.n34] = [x34.LFS). % given sequence x(n) sigshift(x. print -deps2 .’XTickMode’. n = [-3:3]. ytick = [-30:10:60]. [x31.’filled’).’Name’.-5.-3. close all.1). Sequence x3(n) 60 50 40 30 x3(n) 22 20 10 0 −10 −20 −30 −6 −5 −4 −3 −2 −1 0 1 2 3 n Figure 2.n.4.ntick). % x3(n) = x(n + 3)x(n . % fold x(n) sigshift(x34.n36).n.n.-3).n35] = [x36.min(x3)-10.’XTick’.2).-3.’off’.max(x3)+10]). % shift x(-n) by 1 sigshift(x.4.7].x35. % multiply 2 sequences sigfold(x.n34.n)x(n + 1) clc. x3 (n) = x(n + 3)x(n − 2) + x(1 − n)x(n + 1) % P0204c: x(n) = [2.19: Problem P2.3 sequence plot 4 5 . axis([min(n3)-1.n33.2) + x(1 . ylabel(’x_3(n)’.n)..n3] = x = [2.n34] = [x35.ytick). set(gca.’manual’./CHAP2_EPSFILES/P0204c.x36.-1).4.’NumberTitle’.n36] = [x3.n32] = [x33. The plots of x3 (n) is shown in Figure 2. % shift x(n) by -1 sigmult(x34.-5.’P0204c’).’manual’. % shift sequence by 2 sigmult(x31.n33] = [x34.x3. set(Hs.1. Hs = stem(n3. xlabel(’n’.’markersize’.4.1. ntick = n3.2).’YTick’.n32).n31. set(gca.max(n3)+1.n34.’YTickMode’. -5.’manual’.n42. set(Hf_1. -3 <=n <= 3.x. close all.7]. x4 (n) = 2e0.’Name’.max(x4)+10]).7].n42. [x4..n).5*n4).2). set(Hs. ytick = [ -20:10:70]. Hf_1 = figure.5n x (n) + cos (0.1*pi*n4).1.-3.’YTickMode’. xlabel(’n’.1*pi*n)*x(n+2).2006 Solutions Manual for DSP using Matlab (2nd Edition) 4. ntick = n4.ntick). x = [2. Hs = stem(n4.’NumberTitle’.n4.n44] = sigmult(x412.’P0204d’). title(’Sequence x_4(n)’.’manual’.4.max(n4)+1.’XTick’./CHAP2_EPSFILES/P0204d.n. [x42. % given sequence x(n) n4 = [-10:10]. [x44.’YTick’.x4.x43.1.-5. set(gca. The plot of x4 (n) is shown in Figure 2.-2). ylabel(’x_4(n)’. -10 <=n< =10 clc.’filled’). axis([min(n4)-1.20.’FontSize’.’XTickMode’.4. [x43.5n}*x(n)+cos(0.n44).’markersize’.LFS). Sequence x4(n) 70 60 50 x4(n) 40 30 20 10 0 −10 −20 −10 −9 −8 −7 −6 −5 −4 −3 −2 −1 0 1 2 3 4 5 6 n Figure 2.n43).1π n) x (n + 2) .min(x4)-11.4. set(gca.’FontSize’.4 sequence plot 7 8 9 10 23 . n = [-3:3].’FontSize’. % x4(n) = 2*e^{0. −10 ≤ n ≤ 10 % P0204d: x(n) = [2.LFS). x412 = cos(0.n42] = sigmult(x41.x44.’off’.4.TFS). print -deps2 .n43] = sigshift(x.20: Problem P2. x41 = 2*exp(0.n4] = sigadd(x42.4.ytick).-3. ’off’. ntick = [n1(1):20:n1(end)]...real(x1).1 \times j \times pi \times n) ’ char(10) ...LFS). print -deps2 . Hs1 = stem(n1.5 The complex exponential sequence e j ω0 n or the sinusoidal sequence cos (ω0 n) are periodic if the normalized K △ ω0 frequency f 0 = is a rational number. 2.’filled’).’XTickMode’. ’ Period = 20. ylabel(’Real(x_1(n))’.’markersize’..max(n1)+5.1. 2π N 1.imag(x1).21 we see that in one period of 20 samples x1 (n) exhibits cycle. xlabel(’n’.’Name’.LFS).1 \times n)’ char(10) . set(gca. xlabel(’n’. The plots of x1 (n) is shown in Figure 2.’filled’).max(n1)+5.max(x2)+1]). close all..1π n). % P0205b: x1(n) = e^{0.x2. K = 1. print -deps2 . −100 ≤ n ≤ 100.’manual’.’manual’. n1 = [-100:100].2).’FontSize’.max(real(x1))+1]).1n). 3.’P0205c’).1*n2).1.LFS).TFS).1n). Hf_1 = figure.’Name’.’FontSize’.min(x2)-1.’XTickMode’.’FontSize’.. -20 <= n <= 20 clc.’FontSize’. x1 = exp(0.21. ’ Period = 20./Latex/P0205b. Hf_1 = figure. Hs2 = stem(n1. where K and N are integers. set(Hf_1.’markersize’.’XTick’.’off’.’FontSize’. Analytical proof: The exponential sequence is periodic if e j 2π f 0 (n+N) = e j 2π f 0 n or e j 2π f 0 N = 1 ⇒ f 0 N = K (an integer) which proves the result. From the plot in Figure 2. N = 20’].’NumberTitle’. title([’Real part of sequence x_1(n) = ’ .’FontSize’.ntick).1). that is. ylabel(’x_2(n)’./.. axis([min(n1)-5. close all.2). This is true whenever K and N are relatively prime.TFS).ntick).1 \times j \times pi \times n) ’ char(10) .1*j*pi*n} -100 <=n <=100 clc.. set(Hs. K = 1.LFS).’NumberTitle’. ntick = [n1(1):20:n1(end)].24 Solutions Manual for DSP using Matlab (2nd Edition) 2006 P2. title([’Sequence x_2(n) = cos(0.. x1 = exp(0. axis([min(n1)-5. x2 = cos(0.1*j*pi*n1).max(real(x1))+1]). n2 = [-20:20]. ylabel(’Imag(x_1(n))’.’FontSize’. xlabel(’n’. . set(Hs1. N = 20’].’markersize’.2)./CHAP2_EPSFILES/P0205b. axis([min(n2)-1. Hs = stem(n2.LFS).2). ’exp(0.’FontSize’. f 0 = ..’XTick’.’filled’)..1/2 = 1/20 the sequence is periodic.’P0205b’).LFS). ’exp(0. x2 = cos(0. set(Hf_1.min(real(x1))-1.min(real(x1))-1.. % P0205c: x2(n) = cos(0. subplot(2. −20 ≤ n ≤ 20. subplot(2. title([’Imaginary part of sequence x_1(n) = ’ . Since f 0 = 0. set(Hs2. set(gca.max(n2)+1. 22.TFS)..5 0 −0.5 x2(n) 1 0. ’ is not a rational number’]..1 × n) 2 Not periodic since f0 = 0.2 sequence plots ’Not periodic since f_0 = 0.1 / (2 \times \pi)’ . ’FontSize’.5.22.1 / (2 × π) is not a rational number 2 1. set(gca. print -deps2 . The plots of x1 (n) is shown in Figure 2.5 −1 −20 −16 −12 −8 −4 0 4 8 12 16 20 n Figure 2.2006 Solutions Manual for DSP using Matlab (2nd Edition) 25 Sequence x (n) = cos(0. This can be clearly seen from the plot of x2 (n) in Figure 2.21: Problem P2./CHAP2_EPSFILES/P0205c. .’XTickMode’.. ntick = [n2(1):4:n2(end)].’manual’. In this case f 0 is not a rational number and hence the sequence x2 (n) is not periodic.’XTick’.ntick). 3 sequence plots 16 20 .5.5 x2(n) 1 0.1 / (2 × π) is not a rational number 2 1.Solutions Manual for DSP using Matlab (2nd Edition) 26 2006 Sequence x2(n) = cos(0.5 0 −0.22: Problem P2.1 × n) Not periodic since f0 = 0.5 −1 −20 −16 −12 −8 −4 0 4 8 12 n Figure 2. m1] = evenodd(x1. xe(n) Even part of x1(n) 5 4 3 2 1 0 −1 −9 −8 −7 −6 −5 −4 −3 −2 −1 0 1 2 3 4 5 6 7 8 9 4 5 6 7 8 9 n xo(n) Odd part of x1(n) 6 4 2 0 −2 −4 −6 −9 −8 −7 −6 −5 −4 −3 −2 −1 0 1 2 3 n Figure 2.’FontSize’.TFS). 8.LFS).xo1. print -deps2 .’FontSize’. ytick = [-6:2:6].’off’.’FontSize’. 6. clc. set(gca. Hs = stem(m1. 1.’FontSize’.set(gca. Hf_1 = figure. xlabel(’n’. set(Hs. ylabel(’x_o(n)’. 2. subplot(2.ytick).1. 7. axis([min(m1)-1. 1.max(m1)+1.LFS).ntick).’NumberTitle’.’YTick’./. ↑ % P0206a: % Even odd decomposition of x1(n) = [0 1 2 3 4 5 6 7 8 9]. 3.max(xe1)+1]).min(xo1)-2.’FontSize’. ytick = [-1:5].xo1. close all./Latex/P0206a..ytick). [xe1.6.6 Using the evenodd function decompose the following sequences into their even and odd components. 4. 9}.set(gca.’P0206a’). % n = 0:9.1).2006 Solutions Manual for DSP using Matlab (2nd Edition) 27 P2. set(Hf_1.LFS).max(xo1)+2]). set(gca.2).’XTick’. 5.’YTick’..n1). x1 (n) = {0. Hs = stem(m1. title(’Even part of x_1(n)’.ntick). subplot(2.’Name’.xe1. x1 = [0 1 2 3 4 5 6 7 8 9].1 sequence plot . title(’Odd part of x_1(n)’. axis([min(m1)-1.23.LFS).’filled’). The plots of x1 (n) is shown in Figure 2. Plot these components using the stem function.’XTick’.’markersize’. xlabel(’n’. ntick = [m1(1):m1(end)]. set(Hs.2).’filled’).2). ntick = [m1(1):m1(end)]./CHAP2_EPSFILES/P0206a.’markersize’..min(xe1)-1. n1 = [0:9]. ylabel(’x_e(n)’. print -deps2 .max(m1)+1.23: Problem P2.TFS).’FontSize’.1. set(Hs./Latex/P0206b.max(m2)+1.1n) [u(n + 5) .n2).min(xe2)-1. % P0206b: Even odd decomposition of x2(n) = e ^ {0.’NumberTitle’. Even part of x (n) = exp(0. xlabel(’n’.max(m2)+1. [xe2. ntick = [m2(1):2:m2(end)].ntick).1n} [u(n + 5) .m2] = evenodd(x2.12) .10)]’...1n) [u(n + 5) − u(n − 10)] 2 xe(n) 2 1 0 −1 −12 −10 −8 −6 −4 −2 0 2 4 6 8 10 12 n Odd part of x2(n) = exp(0. print -deps2 . Hs = stem(m2.’FontSize’.. subplot(2.LFS).. Hs = stem(m2..*(stepseq(-5. close all.u(n .stepseq(10. clc.LFS).TFS).xo2.’markersize’.10)]’.2).Solutions Manual for DSP using Matlab (2nd Edition) 2006 2. ylabel(’x_e(n)’.’Name’. xlabel(’n’.’FontSize’..max(xe2)+1]). axis([min(m2)-1. ylabel(’x_o(n)’.6.u(n .LFS).’P0206b’). axis([min(m2)-1.1n) [u(n + 5) .’filled’). set(gca. subplot(2.min(xo2)-1.ntick).max(xo2)+1]). x2 (n) = e0.2 sequence plot 8 10 12 . Hf_1 = figure./. set(Hf_1.24: Problem P2.1n [u(n + 5) − u(n − 10)]. x2 = exp(0.1). ’FontSize’.2).12)).2)..’FontSize’.-8.. title(’Odd part of x_2(n) = exp(0.TFS).’XTick’.-8.1n) [u(n + 5) − u(n − 10)] 2 xo(n) 28 0 −2 −12 −10 −8 −6 −4 −2 0 2 4 6 n Figure 2. set(Hs.1. title(’Even part of x_2(n) = exp(0.’filled’).’markersize’. n2 = [-8:12].’XTick’.1*n2). ’FontSize’.1.xo2. print -deps2 .24. ntick = [m2(1) :2:m2(end)].u(n .’off’.’FontSize’.LFS). The plots of x2 (n) is shown in Figure 2. set(gca.10)]./CHAP2_EPSFILES/P0206b..xe2. subplot(2.1.’markersize’. axis([min(m3)-2.’markersize’. ylabel(’x_e(n)’. xe(n) Even part of x3(n) = cos(0.max(m3)+2..25: Problem P2.LFS). title(’Even part of x_3(n) = cos(0...25.n3).1.’FontSize’.max(m3)+2./. % -20 <= n <= 20. print -deps2 . subplot(2.max(xe3)+1]). clc..’filled’).ntick).min(xo3)-1. set(Hs.max(xo3)+1]).’off’. Hs = stem(m3.xe3. set(Hf_1. −20 ≤ n ≤ 20. xlabel(’n’.2006 Solutions Manual for DSP using Matlab (2nd Edition) 3. [xe3.TFS)..m3] = evenodd(x3.’FontSize’.. set(Hs. ’FontSize’. xlabel(’n’. set(gca.’Name’.2). print -deps2 . close all.xo3./CHAP2_EPSFILES/P0206c.2*pi*n + pi/4). Hs = stem(m3. n3 = [-20:20]. % P0206c: Even odd decomposition of x2(n) = cos(0. ’FontSize’.. x3 (n) = cos(0.’XTick’.xo3.2 \times \pi \times n + \pi/4)’. ntick = [m3(1):4:m3(end)]. ylabel(’x_o(n)’.6.LFS).’filled’). set(gca.LFS). title(’Odd part of x_3(n) = cos(0. Hf_1 = figure. ntick = [m3(1):4 :m3(end)].2).’FontSize’. The plots of x3 (n) is shown in Figure 2.’P0206c’)..2 × π × n + π/4) 1 0 −1 −20 −16 −12 −8 −4 0 4 8 12 n Figure 2.ntick).2 × π × n + π/4) 1 0 −1 −20 −16 −12 −8 −4 0 4 8 12 16 20 n xo(n) Odd part of x3(n) = cos(0.LFS).2π n + π/4).2).1).’NumberTitle’.’FontSize’.2 \times \pi \times n + \pi/4)’.3 sequence plot 16 20 29 .’XTick’.2*pi*n3 + pi/4).TFS)..min(xe3)-1. x3 = cos(0. axis([min(m3)-2./Latex/P0206c. xe4. % P0206d: x4(n) = e ^ {-0.LFS).max(m4)+10. 0 <= n <= 100 clc. axis([min(m4)-10. ’exp(-0. Hf_1 = figure.xo4.1. The plots of x1 (n) are shown in Figure 2. ’\pi/3)’]. subplot(2.’XTick’. ntick = [m4(1):20 :m4(end)].. ntick = [m4(1):20:m4(end)].’FontSize’.TFS). ’\pi/3)’]. print -deps2 .’FontSize’.Solutions Manual for DSP using Matlab (2nd Edition) 30 4. ’exp(-0.05*n}*sin(0.xo4.’filled’).1. set(Hs. x4 = exp(-0.TFS).’Name’..2)../.1*pi*n4 + pi/3).2).26.6..1 sequence plot 80 100 2006 . axis([min(m4)-10.LFS).’filled’).min(xo4)-1.2).LFS).1 \times \pi \times n + ’ .1 \times \pi \times n + ’ .m4] = evenodd(x4.. title([’Even part of x_4(n) = ’ .n4).’FontSize’.1 × π × n + π/3) xo(n) 1 0 −1 −100 −80 −60 −40 −20 0 20 40 60 n Figure 2..min(xe4)-1. set(Hf_1.1*pi*n + pi/3). set(gca.’XTick’. xlabel(’n’. 0 ≤ n ≤ 100.05 × n) × sin(0. subplot(2.’off’. ylabel(’x_e(n)’. title([’Odd part of x_4(n) = ’ ./Latex/P0206d..’markersize’. n4 = [0:100].1).LFS). set(Hs.. set(gca.max(xo4)+1]).’NumberTitle’.ntick).1 × π × n + π/3) 1 0 −1 −100 −80 −60 −40 −20 0 20 40 60 80 100 n Odd part of x4(n) = exp(−0. [xe4.26: Problem P2.ntick). print -deps2 . x4 (n) = e−0.05 \times n) \times sin(0..’P0206d’)./CHAP2_EPSFILES/P0206d.05 \times n) \times sin(0.max(xe4)+1]). Hs = stem(m4.’markersize’.’FontSize’. xe(n) Even part of x4(n) = exp(−0.05*n4).max(m4)+10.’FontSize’. ylabel(’x_o(n)’. close all.05 × n) × sin(0. Hs = stem(m4..05n sin(0.’FontSize’..*sin(0. xlabel(’n’.1π n + π/3). ’markersize’. set(Hf_1.ytick). set(Hs.’YTick’. xlabel(’n’.min(Re_xo)-1. Im_xe = imag(xe). xlabel(’n’. .’off’.TFS). Im_xo = imag(xo).min(Re_xe)-2.2). ytick = [min(Re_xe)-2:2:max(Re_xe)+2]. % 0 < = n <= 10 % into its conjugate symmetric and conjugate antisymmetric parts./Latex/P0207b.’FontSize’.Re_xo). n = [0:10].max(Re_xo)+1]).TFS).2π ]n). title([’Real part of’ char(10) ’even sequence x_e(n)’]. subplot(2.4).Im_xe).’FontSize’.LFS). x(n) = 10 exp([−0. title([’Imaginary part of’ char(10) ’even sequence x_e(n)’]. Hs = stem(neo.LFS). Then any arbitrary complex-valued sequence x(n) can be decomposed into x(n) = xe (n) + xo (n) where xe (n) and xo (n) are given by     and xo (n) = 12 x(n) − x ∗ (−n) (2. The plots of x(n) are shown in Figure 2. Modify the evenodd function discussed in the text so that it accepts an arbitrary sequence and decomposes it into its conjugate-symmetric and conjugate-antisymmetric components by implementing (2.’FontSize’. subplot(2.2.ytick).Im_xo).’FontSize’. Hs = stem(neo.1 + j*0./. x = 10*(-0.’YTick’.1). subplot(2. 1.1 +  0.’NumberTitle’.2*pi)*n}.max(neo)+1.’P0207b’).’YTick’. set(gca. clc.’FontSize’.min(Im_xo)-10.2). title([’Real part of’ char(10) ’odd sequence x_o(n)’].2006 Solutions Manual for DSP using Matlab (2nd Edition) 31 P2.LFS). ytick = [-6:2:6]. axis([min(neo)-1. set(gca. [xe. Re_xe = real(xe). set(Hs.’markersize’.ytick)..’markersize’.’FontSize’.’FontSize’.LFS). ylabel(’Im[x_e(n)]’.’YTick’. xlabel(’n’.print -deps2 .LFS).’FontSize’.’FontSize’..2.’Name’. axis([min(neo)-1.max(neo)+1.LFS).. Hf_1 = figure. Re_xo = real(xo).2).LFS).’FontSize’./CHAP2_EPSFILES/P0207b.2.2*pi)*n. axis([min(neo)-1.1) xe (n) = 12 x(n) + x ∗ (−n) respectively. Hs = stem(neo. ytick = [-40:20:40].max(Im_xo)+10]). ylabel(’Im[x_o(n)]’.’FontSize’.3).max(neo)+1. 2.neo] = evenodd(x. set(gca. set(Hs. set(Hs.1).2). axis([min(neo)-1.’FontSize’.LFS).2). xlabel(’n’.40]).xo.1+j*0. ytick = [-10:10:40]. subplot(2. 0 ≤ n ≤ 10 % P0207b: Decomposition of x(n) = 10*e ^ {(-0. close all. Hs = stem(neo. ylabel(’Re[x_o(n)]’.n).27.’markersize’.7 A complex-valued sequence xe (n) is called conjugate-symmetric if xe (n) = xe∗ (−n) and a complex-valued sequence xo (n) is called conjugate-antisymmetric if xo (n) = −xo∗ (−n). set(gca.ytick).TFS).-40. print -deps2 .max(neo)+1.max(Re_xe)+2]).2.Re_xe). title([’Imaginary part of’ char(10) ’odd sequence x_o(n)’]. ylabel(’Re[x_e(n)]’.TFS). 27: Problem P2.Solutions Manual for DSP using Matlab (2nd Edition) Re[xo(n)] 1 −1 −3 −5 −7 −10 −5 0 5 2006 Real part of odd sequence xo(n) 10 6 4 2 0 −2 −4 −6 −10 −5 0 5 10 n n Imaginary part of even sequence xe(n) Imaginary part of odd sequence xo(n) 40 20 0 −20 −40 −10 Im[xo(n)] Re[xe(n)] Real part of even sequence xe(n) Im[xe(n)] 32 −5 0 5 10 40 30 20 10 0 −10 −10 −5 n Figure 2.7.2 sequence plot 0 n 5 10 . xlabel(’n’. ytick = [-1.’markersize’. 1. % P0208b: x1(n) = sin(0. set(gca.LFS). subplot(2.5]).n1.’markersize’. x(n) = sin(0. ylabel(’x(n)’. ytick = [-1. set(gca.LFS). set(Hs. ntick = [n2(1):10:n2(end)].TFS).5. set(Hs.m2] = dnsample(x2.LFS).4). Hs = stem(m1.’off’.5].2).2006 Solutions Manual for DSP using Matlab (2nd Edition) 33 P2.max(n1)+5.1.5*pi*n). % P0208c: x2(n) = sin(0.5:1.max(x2)+0.min(y2)-1.5]. ’FontSize’. set(Hs..LFS). 3. set(gca.TFS).TFS).1).4).5:1.125π n).’NumberTitle’.5].1.’markersize’.5:0. set(Hs. subplot(2. n2 = [-50:50]. xlabel(’n’. close all. ntick = [m1(1):2:m1(end)]. set(Hf_1.125*pi*n).’FontSize’. axis([min(n2)-5.max(m2)+1.y2). set(Hf_1./CHAP2_EPSFILES/P0208b.’YTick’.5.’FontSize’. Matlab function: 2.LFS). Hs = stem(n2..ytick).5:0. ylabel(’x(n)’.5]).2).min(x1)-0.’FontSize’.ntick).’FontSize’. [y1..’FontSize’.1.ntick). [y2.1).’YTick’.-50 <= n <= 50 % Decimate x2(n) by a factor of 4 to obtain y2(n) clc.LFS).’P0208b’). title(’y_1(n) = Original sequence x_1(n) decimated by a factor of 4’.’FontSize’.x1).min(y1)-0. Observe that the original signal x1 (n) can be recovered. print -deps2 . xlabel(’n’. close all.y1). The plots of x1 (n) and y1 (n) are shown in Figure 2.max(y2)+1]).m1] = dnsample(x1. Hf_1 = figure. n1 = [-50:50]. ylabel(’y(n) = x(4n)’.2). x1 = sin(0.5*pi*n2).’FontSize’. −50 ≤ n ≤ 50.’FontSize’.’Name’. xlabel(’n’.’off’.125*pi*n1).n2. ylabel(’y(n) = x(4n)’.max(m1)+2. Hs = stem(m2.’XTick’.’Name’.-50 <= n <= 50 % Decimate x(n) by a factor of 4 to obtain y(n) clc. ntick = [n1(1):10:n1(end)]. x1 (n) = sin(0.’YTick’.’P0208c’).ytick).ntick).5]).2).’NumberTitle’.LFS). x2 = sin(0.5:1.ytick).max(y1)+0.5.’XTick’.5π n). set(gca. axis([min(m2)-1.’FontSize’.1.. set(gca. title(’Original sequence x_1(n)’. axis([min(n1)-5. axis([min(m1)-2. −50 ≤ n ≤ 50.8 The operation of signal dilation (or decimation or down-sampling) is defined by y(n) = x(n M) in which the sequence x(n) is down-sampled by an integer factor M.2).max(x1)+0. subplot(2.2).max(n2)+5.’FontSize’.min(x2)-0. Hf_1 = figure.5:0. . subplot(2. title(’Original sequence x_2(n)’.LFS). ytick = [-1. Decimation by a factor of 4.28.x2). set(gca. Decimation by a factor of 4. Hs = stem(n1.’XTick’.’markersize’. 29: Problem P2... ntick = [m2(1):2:m2(end)].5 −1 −1.5 −12 −10 −8 −6 −4 −2 0 2 4 6 8 10 12 n Figure 2.5 −1 −1..8. set(gca.8.29.5 1 0./CHAP2_EPSFILES/P0208c.5 1 0.. print -deps2 .3 sequence plot 10 12 ../Latex/P0208c. x(n) Original sequence x2(n) 1. Thus the original signal x2 (n) is lost. print -deps2 .Solutions Manual for DSP using Matlab (2nd Edition) 34 2006 Original sequence x (n) x(n) 1 1.TFS).5 0 −0.ntick). ’FontSize’.5 −50 −40 −30 −20 −10 0 10 20 30 40 50 n y(n) = x(4n) y2(n) = Original sequence x2(n) decimated by a factor of 4 1 0 −1 −12 −10 −8 −6 −4 −2 0 2 4 6 8 n Figure 2.’XTick’../. Observe that the downsampled signal is a signal with zero frequency.5 −50 −40 −30 −20 −10 0 10 20 30 40 50 n y (n) = Original sequence x (n) decimated by a factor of 4 y(n) = x(4n) 1 1 1.5 −1 −1.5 0 −0.28: Problem P2. The plots of x2 (n) and y2 (n) are shown in Figure 2.2 sequence plot title(’y_2(n) = Original sequence x_2(n) decimated by a factor of 4’.5 0 −0.5 1 0. 9)n . The plot of the autocorrelation is shown in Figure 2.nrxx] = conv_m(x.nx.’markersize’.8)−n .^ nx. set(gca. x = 0.^ ny.’NumberTitle’./. 0 <= n <= 20 % with sequence y = 0. close all. title(’Autocorrelation of x(n)’. x = 0.8 . [rxx. nx = [0:20]..30./Latex/P0209a. close all.’Name’.max(rxx)+1]).2).ntick).9 ^ n. % using the conv_m function clc.8.min(rxx). y = 0. Hf_1 = figure.nyf] = sigfold(y.’FontSize’.TFS).nx). Autocorrelation of x(n) 6 5 rxx(n) 4 3 2 1 −20 −16 −12 −8 −4 0 4 8 12 16 20 n Figure 2. set(Hf_1. y(n) = (0.max(nrxx)+1. -20 <=n <= 0 using the conv_m function clc.xf.yf.LFS). ny = [-20:0]..9 The autocorrelation sequence r x x (ℓ) and the crosscorrelation sequence r x y (ℓ) for the sequences: x(n) = (0. Hs = stem(nrxx./CHAP2_EPSFILES/P0209a.nrxy] = conv_m(x.30: Problem P2.2006 Solutions Manual for DSP using Matlab (2nd Edition) 35 P2.9 .’P0209a’).’FontSize’.. ylabel(’r_x_x(n)’. [rxy. axis([min(nrxx)-1.^n.ny). [yf. print -deps2 .nxf] = sigfold(x.nx.nxf).9 .rxx).9 ^ n. −20 ≤ n ≤ 0 0 <= n <= 20 nx = [0:20]. % P0209a: autocorrelation of sequence x(n) = 0. ntick = [nrxx(1):4:nrxx(end)]. print -deps2 . [xf. xlabel(’n’. set(Hs.nyf).’FontSize’.’off’.^ nx. 0 ≤ n ≤ 20. .LFS).’XTick’.9 autocorrelation plot % P0209b: crosscorrelation of sequence x(n) = 0. ’off’. set(Hs.2).Solutions Manual for DSP using Matlab (2nd Edition) Hf_1 = figure.’P0209b’).max(rxy)+20]). set(gca. set(gca. print -deps2 ./CHAP2_EPSFILES/P0209b. The plot of the crosscorrelation is shown in Figure 2.LFS). set(Hf_1.’Name’.31.ytick). ytick = [0:50:300 320].’YTick’. title(’Crosscorrelation of x(n) and y(n)’. axis([min(nrxy)-1.’XTick’.’FontSize’.TFS). ntick = [nrxy(1):2:nrxy(end)].ntick). ylabel(’r_x_y(n)’.31: Problem P2. xlabel(’n’.min(rxy)-1.’FontSize’.rxy).’FontSize’.’NumberTitle’.9 crosscorrelation plot 2006 ..max(nrxy)+1.LFS). Crosscorrelation of x(n) and y(n) 320 300 250 200 rxy(n) 36 150 100 50 0 0 2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 40 n Figure 2. Hs = stem(nrxy.’markersize’. α = 0.2006 Solutions Manual for DSP using Matlab (2nd Edition) 37 P2. and k = 50. Generate 200 samples of y(n) and determine its autocorrelation. Let y(n) = x(n) + αx(n − k) where k is the amount of delay in samples and α is its relative strength.2π n) + 0.10 In a certain concert hall.6π n). 2. Determine analytically the autocorrelation r yy (ℓ) in terms of the autocorrelation r x x (ℓ). The audio signal experienced by the listener y(n) is a combination of x(n) and its echoes.5 cos(0. We want to estimate the delay using the correlation analysis. Let x(n) = cos(0. Can you obtain α and k by observing r yy (ℓ)? .1. echoes of the original audio signal x(n) are generated due to the reflections at the walls and ceiling. 1. [x11. u = stepseq(0.ny] = sigadd(xs.n.*u. clc.x111.n.ny1] = sigadd(x1.nxs11). Analytic determination of linearity: T2 [a1 x1 (n) + a2 x2 (n)] = {a1 x1 (n) + a2 x2 (n)} + n {a1 x1 (n + 1) + a2 x2 (n + 1)} = a1 {x1 (n) + n x1 (n + 1)} + a2 {x2 (n) + n x2 (n + 1)} = a1 T2 [x1 (n)] + a2 T2 [x2 (n)] Hence the system is T2 [x(n)] linear.length(n)).x11.100). [x111.nx211). diff = sum(abs(y . 2.n. Matlab script: % P0211b: To prove that the system T2[x(n)] = x(n) + n*x(n+1) is linear clear. Analytic determination of linearity: T1 [a1 x1 (n) + a2 x2 (n)] = {a1 x1 (n) + a2 x2 (n)}u(n) = a1 x1 (n)u(n) + a2 x2 (n)u(n) = a1 T1 [x1 (n)] + a2 T1 [x2 (n)] Hence the system T1 [x(n)] is linear.0. x2 = sqrt(10)*randn(1.n. diff = sum(abs(y .(y1 + y2))). [y1.length(n)).11 Linearity of discrete-time systems. 2. System-1: T1 [x(n)] = x(n)u(n) 1. close all. [y2.nxs1).xs11. clc. [xs11. z = n.n. xs = x1 + x2.nx111] = sigmult(z. [xs1. [y. if (diff < 1e-5) disp(’ *** System-2 is Linear *** ’). [x21.xs1.n.n. x2 = sqrt(10)*randn(1.(y1 + y2))). x1 = rand(1.nx11).nx111).nx21] = sigshift(x2.-1). y2 = x2.-1). y = (x1 + x2). else disp(’ *** System-1 is NonLinear *** ’).nx11] = sigshift(x1. end Matlab verification: >> *** System-1 is Linear *** System-2: T2 [x(n)] = x(n) + n x(n + 1) 1.nxs11] = sigmult(z.nx21). Matlab script: % P0211a: To prove that the system T1[x(n)] = x(n)u(n) is linear clear. y1 = x1.n.x21. n = 0:100.38 Solutions Manual for DSP using Matlab (2nd Edition) 2006 P2. if (diff < 1e-5) disp(’ *** System-1 is Linear *** ’).length(n)). .length(n)).nx211] = sigmult(z.ny2] = sigadd(x2.-1). n = 0:100. [x211.nxs1] = sigshift(xs.*u. close all. x1 = rand(1.*u.n.x211. nxs2. [x11. [y2.nx13] = dnsample(x1.nxs1.nxs2] = sigshift(xs.2).x25. xs = x1 + x2. [x23. xs2 = -1/3*xs2.nx11] = sigshift(x1. n = [0:100]. close all.nx15] = sigadd(x11. [x22.nx23] = dnsample(x2.nx13). diff = sum(abs(y . [x13.length(n)). [xs4. x2 = sqrt(10)*randn(1. [y1.n. [xs2. The product term in the input-output equation makes the system T3 [x(n)] nonlinear.x15.nx14] = sigmult(x12.nx24] = sigmult(x22. Matlab script: % P0211c: To prove that the system T3[x(n)] = x(n) + 1/2*x(n . [xs1.nx21] = sigshift(x2.nx21.x14.(y1 + y2))).n.x24. end Matlab verification: >> *** System-3 is NonLinear *** P System-4: T4 [x(n)] = n+5 k=−∞ 2x(k) .x23. x1 = rand(1. xs1 = 1/2*xs1. else disp(’ *** System-3 is NonLinear *** ’).nxs4). [x24.n.n.nx15).2).nx11.nx23).xs3. [x21.nxs3). x22 = -1/3*x22.n.nx12] = sigshift(x1.ny1] = sigadd(x1. [y.length(n)).2006 Solutions Manual for DSP using Matlab (2nd Edition) 39 else disp(’ *** System-2 is NonLinear *** ’).ny2] = sigadd(x2.nxs4] = sigmult(xs2. x12 = -1/3*x12. x21 = 1/2*x21. 2.ny] = sigadd(xs.nxs5).3)*x(2n) % is linear clear. [x14. [xs5.n. [x12. Analytic determination of linearity: T3 [a1 x1 (n) + a2 x2 (n)] = a1 x1 (n) + a2 x2 (n) + 12 {a1 x1 (n − 2) + a2 x2 (n − 2)} − 13 {a1 x1 (n − 3) + a2 x2 (n − 3)}{a1 x1 (2n) + a2 x2 (2n)}  = a1 x1 (n) + 12 x1 (n − 2) − 13 a1 x1 (n − 3)x1 (2n)  + a2 x2 (n) + 12 x2 (n − 2) − 13 a2 x2 (n − 3)x2 (2n) + 13 {a1 x1 (n − 3)a2 x2 (2n) + a2 x2 (n − 3)a1 x1 (2n)} which clearly is not equal to a1 T3 [x1 (n)]+a2 T3 [x2 (n)].nxs1] = sigshift(xs.n.2).nx22.n.n.2).2) % .2).nx24).3).nxs3] = dnsample(xs. if (diff < 1e-5) disp(’ *** System-3 is Linear *** ’). [x25.x13.nxs5] = sigadd(xs1. [xs3.1/3*x(n .nx22] = sigshift(x2.n.xs4.3).n.nx25).nx12. [x15. clc. end Matlab verification: >> *** System-2 is Linear *** System-3: T3 [x(n)] = x(n) + 12 x(n − 2) − 13 x(n − 3)x(2n) 1.2).3).xs5. x11 = 1/2*x11.nx25] = sigadd(x21.nx14).n. clc. xs = x1 + x2. [y1. diff = sum(abs(y . close all.n. if (diff < 1e-5) disp(’ *** System-5 is Linear *** ’). x2 = sqrt(10)*randn(1. if (diff < 1e-5) disp(’ *** System-4 is Linear *** ’). Matlab script: % P0211e: To prove that the system T5[x(n)] = clear.5.2).5.2). x1 = rand(1. else disp(’ *** System-5 is NonLinear *** ’). n = [0:100]. xs = x1 + x2. clc. [y. else disp(’ *** System-4 is NonLinear *** ’). end Matlab verification: >> *** System-5 is Linear *** System-6: T6 [x(n)] = round[x(n)] .ny] = dnsample(xs. Matlab script: % P0211d: To prove that the system T4[x(n)] = sum_{k=-infinity}^{n+5}2*x(k) % is linear clear.(y1 + y2))). diff = sum(abs(y . x1 = rand(1.length(n)). [y2. end Matlab verification: >> *** System-4 is Linear *** System-5: T5 [x(n)] = x(2n) 1.2). Analytic determination of linearity: T4 [a1 x1 (n) + a2 x2 (n)] = n+5 X k=−∞ 2{a1 x1 (k) + a2 x2 (k)} = a1 = a1 T4 [x1 (n)] + a2 T4 [x2 (n)] n+5 X k=−∞ 2x1 (k) + a2 n+5 X 2x2 (k) k=−∞ Hence the system T4 [x(n)] is linear.40 Solutions Manual for DSP using Matlab (2nd Edition) 2006 1. close all. 2. y2 = cumsum(x2). x(2n) is linear n = 0:100.length(n)).length(n)). ny = n . x2 = sqrt(10)*randn(1.n. y1 = cumsum(x1). Analytic determination of linearity: T5 [a1 x1 (n) + a2 x2 (n)] = a1 x1 (2n) + a2 x2 (2n) = a1 T5 [x1 (n)] + a2 T5 [x2 (n)] Hence the system T5 [x(n)] is linear. y = cumsum(xs).ny2] = dnsample(x2. 2.length(n)).5.(y1 + y2))).ny1] = dnsample(x1. ny1 = n . ny2 = n .n. Matlab script: % P0211f: To prove that the system T6[x(n)] = clear.length(n)). y = round(xs). Analytic determination of linearity: T6 [a1 x1 (n) + a2 x2 (n)] = round[a1 x1 (n) + a2 x2 (n)] 6 = a1 round[x1 (n)] + a2 round[x2 (n)] Hence the system T6 [x(n)] is nonlinear. round(x(n)) is linear n = 0:100. close all. y1 = round(x1).2006 Solutions Manual for DSP using Matlab (2nd Edition) 1. x2 = sqrt(10)*randn(1. y2 = round(x2). end Matlab verification: >> *** System-6 is NonLinear *** 41 . else disp(’ *** System-6 is NonLinear *** ’). clc. if (diff < 1e-5) disp(’ *** System-6 is Linear *** ’). xs = x1 + x2.(y1 + y2))). diff = sum(abs(y .length(n)). x1 = rand(1. 2. ny1.n.42 Solutions Manual for DSP using Matlab (2nd Edition) 2006 P2. [y2. [xs11.nx11] = sigmult(z. close all.n). 2.ny2).nx1.ndiff] = sigadd(y1. [x11.u. else disp(’ *** System-2 is Time-Varying *** ’).ny1.*u.nxs1). n = 0:100.ndiff] = sigadd(y1.ny] = sigadd(x. [y2.nx1] = sigshift(x. end Matlab verification: >> *** System-1 is Time-Varying *** System-2: T2 [x(n)] .length(n)). if (diff < 1e-5) disp(’ *** System-1 is Time-Invariant *** ’).ny1] = sigshift(y. y = x.n. [xs1.xs11. [xs.ny .n. y(n) = x(n) + n x(n + 1) 1. n = 0:100. x = sqrt(10)*randn(1.-1).1).-y2.0. diff = sum(abs(diff)).100).x11. y(n) = x(n)u(n) 1.nxs11] = sigmult(z. x = sqrt(10)*randn(1.x1.nx11).nxs. [x1. close all.n. if (diff < 1e-5) disp(’ *** System-2 is Time-Invariant *** ’).xs1.ny2] = sigmult(x1. System-1: T1 [x(n)] . diff = sum(abs(diff)).nxs] = sigshift(x.n.nxs1] = sigshift(xs.1). clc. [x1. Matlab script: % P0212b: To determine whether the system T2[x(n)] = x(n) + n*x(n + 1) is % time-invariant clear.nxs. [diff.1). else disp(’ *** System-1 is Time-Varying *** ’).nxs11).1). [y. u = stepseq(0.ny2). [y1. Matlab script: % P0212a: To determine whether T1[x(n)] = x(n)u(n) is time invariant clear.length(n)).-1).n. [y1.ny1] = sigshift(y. clc.nx1] = sigshift(x. Analytic determination of time-invariance: T2 [x(n − k)] = x(n − k) + n x(n − k + 1) 6 = x(n − k) + (n − k) x(n − k + 1) = y(n − k) Hence the system is T2 [x(n)] time-varying.12 Time-invariance of discrete-time systems.-y2. end .ny2] = sigadd(xs.n. z = n. Analytic determination of time-invariance: T1 [x(n − k)] = x(n − k)u(n) 6 = x(n − k)u(n − k) = y(n − k) Hence the system T1 [x(n)] is time-varying. [diff.nx1). 2. n = 0:100.nx5] = sigadd(x1.nxs.ndiff] = sigadd(y1.nxs1. if (diff < 1e-5) disp(’ *** System-3 is Time-Invariant *** ’).5.nx3] = dnsample(x.n.nxs.nx3).xs5.ny2).nx5).n. [diff. [y2. [x4.length(n)).length(n)).nxs4] = sigmult(xs2. [x5.nxs] = sigshift(x.ny] = sigadd(x. xs2 = -1/3*xs2.nx4] = sigmult(x2. [xs.nxs3).2) % .1/3*x(n . end Matlab verification: >> *** System-3 is Time-Varying *** P System-4: T4 [x(n)] .ny1] = sigshift(y. Matlab script: % P0212d: To find whether the system T4[x(n)]=sum_{k=-infinity}^{n+5}2*x(k) % is time-invariant clear. x = sqrt(10)*randn(1.2006 Solutions Manual for DSP using Matlab (2nd Edition) 43 Matlab verification: >> *** System-1 is Time-Varying *** System-3: T3 [x(n)] . [xs4. xs1 = 1/2*xs1. clc.2).1).nxs2] = sigshift(xs.3)*x(2n) % is time invariant clear.ny2] = sigadd(xs. close all. close all. [y1. [x2.x3.3). [xs3. [x1. y = cumsum(x). Analytic determination of time-invariance: 1 T3 [x(n − k)] = x(n − k) + x(n − k − 2) − 2 1 6 = x(n − k) + x(n − k − 2) − 2 1 x(n − k − 3)x(2n − k) 3 1 x(n − k − 3)x(2n − 2k) = y(n − k) 3 Hence the system is T3 [x(n)] time-varying.2). clc. n = 0:100.2).nx1] = sigshift(x.-y2. y(n) = x(n) + 12 x(n − 2) − 13 x(n − 3)x(2n) 1.nxs4). 2.ny1. Analytic determination of time-invariance: T4 [x(n − ℓ)] = n+5 X k=−∞ 2x(k − ℓ) = n−ℓ+5 X k=−∞ 2x(k) = y(n − ℓ) Hence the system T4 [x(n)] is time-invariant.x5.n. [xs2.n.nxs1] = sigshift(xs.nxs.3). x = sqrt(10)*randn(1. [y.n. [x3. x1 = 1/2*x1. [xs1.2).ny.nxs.nxs3] = dnsample(xs.nx4).nxs5).xs3.nx2] = sigshift(x. [xs5. diff = sum(abs(diff)).xs4.nxs5] = sigadd(xs1.nx2. y(n) = n+5 k=−∞ 2x(k) 1. Matlab script: % P0212c: To find whether the system T3[x(n)] = x(n) + 1/2*x(n .1). x2 = -1/3*x2. 2. else disp(’ *** System-3 is Time-Varying *** ’).x4. ny = n .nxs2. .nx1. -y2. if (diff < 1e-5) disp(’ *** System-4 is Time-Invariant *** ’). x = sqrt(10)*randn(1.ndiff] = sigadd(y1.44 Solutions Manual for DSP using Matlab (2nd Edition) 2006 [y1.nxs] = sigshift(x.ny. diff = sum(abs(diff)).ny] = dnsample(x. Analytic determination of time-invariance: T6 [x(n − k)] = round[x(n − k)] = y(n − k) Hence the system T6 [x(n)] is time-invariant.ny1. 2. 2.-1). [diff. y = round(x). 1e-5) *** System-6 is Time-Invariant *** ’). sigshift(y.n.ny1] = sigshift(y.1).-y2.ndiff] = sigadd(y1.ny2] = dnsample(xs.length(n)).nxs] = sigshift(x. clc. [xs. clc. if (diff < disp(’ else disp(’ end x = sqrt(10)*randn(1. y2 = cumsum(xs).ny2). ny2 = nxs .ny. n = 0:100. y(n) = round[x(n)] 1. *** System-6 is Time-Varying *** ’).ny2). [diff. [y2. if (diff < 1e-5) disp(’ *** System-5 is Time-Invariant *** ’).n. Matlab script: % P0212f: To determine if the system T6[x(n)]=round(x(n)) is time-invariant clear.ny1.n. [xs. y(n) = x(2n) 1. diff = sum(abs(diff)).1).ny1] = sigshift(y.length(n)).ny1. end Matlab verification: >> *** System-4 is Time-Invariant *** System-5: T5 [x(n)] . y2 = round(xs).ny1] = ny2 = nxs.2). ny = n.2). n = 0:100. [y1. close all. close all. [xs.ny2). else disp(’ *** System-5 is Time-Varying *** ’). [y1.n. .-1).-y2. Matlab script: % P0212e: To determine whether the system T5[x(n)] = x(2n) is time-invariant clear. end Matlab verification: >> *** System-5 is Time-Varying *** System-6: T6 [x(n)] .nxs] = sigshift(x.ndiff] = sigadd(y1. diff = sum(abs(diff)). [y.nxs.1). else disp(’ *** System-4 is Time-Varying *** ’). [diff.5.1). Analytic determination of time-invariance: T5 [x(n − k)] = x(2n − k) 6 = x[2(n − k)] = y(n − k) Hence the system T5 [x(n)] is time-varying.ny. 2006 Solutions Manual for DSP using Matlab (2nd Edition) Matlab verification: >> *** System-6 is Time-Invariant *** 45 . P System-4: T4 [x(n)] . y(n) = x(n)u(n): This system is stable since |y(n)| = |x(n)|. System-6: T6 [x(n)] . y(n) = x(2n): This system is stable since |y(n)| = |x(2n)| < ∞ for |x(n)| < ∞.13 Stability and Causality of Discrete-time Systems System-1: T1 [x(n)] . . It is also causal since the output depends only on the present value of the input. System-3: T3 [x(n)] . y(n) = x(n) + 12 x(n − 2) − 13 x(n − 3)x(2n): This system is stable since |y(n)| ≤ |x(n)| + 12 |x(n − 2)| + 13 |x(n − 3)| |x(2n)| < ∞ for |x(n)| < ∞ It is however is noncausal since y(1) needs x(2) which is a future input value. System-5: T5 [x(n)] .46 Solutions Manual for DSP using Matlab (2nd Edition) 2006 P2. System-2: T2 [x(n)] . y(n) = x(n) + n x(n + 1): This system is unstable since |y(n)| ≤ |x(n)| + |n| |x(n + 1)| ր ∞ as n ր ∞ for |x(n)| < ∞ It is also noncausal since the output y(n) depends on the future input value x(n + 1) for n > 0. y(n) = n+5 k=−∞ 2x(k): This system is unstable since |y(n)| ≤ 2 n+5 X k=−∞ |x(k)| ր ∞ as n ր ∞ for |x(n)| < ∞ It is also noncausal since the output y(n) depends on the future input value x(n + 5) for n > 0. y(n) = round[x(n)]: This system is stable and causal. It is however noncausal since y(1) needs x(2) which is a future input value. Commutation: ∞ X x1 (n) ∗ x2 (n) = k=−∞ ∞ X = m=−∞ x1 (k) x2 (n − k}) = | {z =m ∞ X m=−∞ x1 (n − m) x2 (m) x2 (m) x1 (n − m) = x2 (n) ∗ x1 (n) Association: [x1 (n) ∗ x2 (n)] ∗ x3 (n) = = = = = " ∞ X x1 (k) x2 k=−∞ ∞ ∞ X X m=−∞ k=−∞ ∞ X k=−∞ ∞ X k=−∞ ∞ X k=−∞ (n − k) ∗ x3 (n) x1 (k) x2 (m − k) x3 (n − m)  x1 (k)  ∞ X m=−∞ x1 (k) # " ∞ X m=−∞  x2 (m − k})x3 (n − m) | {z =ℓ # x2 (ℓ) x3 (n − k − ℓ) x1 (k) [x2 (n − k) ∗ x3 (n − k)] = x1 (n) ∗ [x2 (n) ∗ x3 (n)] Distribution: x1 (n) ∗ [x2 (n) + x3 (n)] = = ∞ X k=−∞ ∞ X k=−∞ x1 (k) [x2 (n − k) + x3 (n − k)] x1 (k) x2 (n − k) + ∞ X k=−∞ x1 (k) x3 (n − k) = x1 (n) ∗ x2 (n) + x1 (n) ∗ x3 (n) Identity: x (n) ∗ δ (n − n 0 ) = ∞ X k=−∞ x (k) δ (n − n 0 − k) = x (n − n 0 ) since δ (n − n 0 − k) = 1 for k = n − n 0 and zero elsewhere. x1 (n) ∗ x2 (n) [x1 (n) ∗ x2 (n)] ∗ x3 (n) x1 (n) ∗ [x2 (n) + x3 (n)] x (n) ∗ δ (n − n 0 ) = = = = x2 (n) ∗ x1 (n) x1 (n) ∗ [x2 (n) ∗ x3 (n)] x1 (n) ∗ x2 (n) + x1 (n) ∗ x3 (n) x (n − n 0 ) : : : : Commutation Association Distribution Identity 1.2006 Solutions Manual for DSP using Matlab (2nd Edition) P2.14 Properties of linear convolution. 47 . -x13.ny2] = conv_m(x2. [x22.0.-10.n22] = stepseq(0.e.n1.ny1] = conv_m(x1. x11 = cos(pi*n1 / 4).x2(n)) = conv(x2(n). ydiff = max(abs(y1 .n14] = sigadd(x12.25).25).x3(n)) = conv(x1(n). n3 = -10:10. x2 = x21.n23] = stepseq(20.n13). [x14.n22] = stepseq(0. [x23.0. [x23.e.*x14. [y1. n1 = -10:30.^ -n2. close all.x2(n)).30).ny2] = conv_m(x2.n12] = stepseq(-5.x2.ny2)).x23. x3 = round((rand(1. [y2.y2)).n13] = stepseq(25.ny1] = conv_m(x1. Matlab verification: ydiff = 0 ndiff = 0 Distribution Matlab script: % P0214c: To prove the Distribution property of convolution % i. clc.n14] = sigadd(x12. x1(n)) clear. clc. n11 = n1.-10. close all. x21 = 0. [x13.ny1. x1 = x11.n13] = stepseq(25. [x14.n3).n2).x23.21)*2 . ndiff = max(abs(ny1 .9 .n2. n2 = 0:25. [x22.n3). [x13.e. conv(x1(n). Verification using Matlab: Commutation Matlab script: % P0214a: To prove the Commutation property of convolution % i.30).*x24. n1 = -10:30. [y2. [x12. x3 = round((rand(1.-10.n12.30).x1. [x12.(x2(n)+x3(n)))=conv(x1(n). x24 = x22 .x2(n))+conv(x1(n). x21 = 0.*x24.25).1)*5).n23] = stepseq(20. [y2.n1). % Association property [y1.x3(n)) clear. n11 = n1.x3. x24 = x22 .n13).30). n2 = 0:25. conv(conv(x1(n).y2. x11 = cos(pi*n1 / 4). Matlab verification: ydiff = 0 ndiff = 0 Association Matlab script: % P0214b: To prove the Association property of convolution % i. % Commutative property [y1.n12] = stepseq(-5. clc.x2. ydiff = max(abs(y1 .^ -n2.y2)).n1.x3.ny2). . x2 = x21. conv(x1(n).ny1] = conv_m(y1.n2).n1.ny2)). x1 = x11.*x14.21)*2 . ndiff = max(abs(ny1 .1)*5). n3 = -10:10.n2. close all.0.n12.ny2] = conv_m(x1.-10.0.conv(x2(n).x3(n))) clear.9 .25).-x13.48 Solutions Manual for DSP using Matlab (2nd Edition) 2006 2. n2 = 0:25.n3). x11 = cos(pi*n1 / 4). [x14.ny1).ny21] = conv_m(x2. ny1diff = max(abs(ny11 .ny3). y3diff = max(abs(y31 .n1.n0).n13).n3). [x13. [y32.n0).dl. [y11. close all. x1 = x11.n1.n2).n13] = stepseq(25.y22)). y2diff = max(abs(y21 .y4)).x3.n3.-x13. [x22.n2.ndl] = impseq(n0.ny31] = conv_m(x3. [y12.n13).n22] = stepseq(0. [dl. n3 = -10:10.30).*x24. Matlab verification: ydiff = 0 ndiff = 0 .n1.ny3] = conv_m(x1.21)*2 .y3. x2 = x21.n23] = stepseq(20.ny22] = sigshift(x2.ny1] = sigadd(x2.y32)).ny2.0.x23.*x14.1)-0. ndiff = max(abs(ny1 .25). n11 = n1.y12)).ny32)).0.x2.*x14.-x13.-10.ny22)). [x22.n0).25). ny3diff = max(abs(ny31 . [y1. [x12.n12.ny11] = conv_m(x1.e. x24 = x22 .n13] = stepseq(25. clc.ny32] = sigshift(x3. [x23. % Identity property n0 = fix(100*rand(1. [y4. Matlab verification: ydiff = 0 ndiff = 0 Identity Matlab script: % P0214d: To prove the Identity property of convolution % i.1)*5). x24 = x22 .n0) clear.-10.0. [x14.n12] = stepseq(-5. n3 = -10:10. x1 = x11.dl.ndl).n1.ny4)). conv(x(n).25). [x12.ny12)). n1 = -10:30.2006 Solutions Manual for DSP using Matlab (2nd Edition) 49 n1 = -10:30.n14] = sigadd(x12.9 . [y21. [y31.n0).n14] = sigadd(x12.0.n2.ny12] = sigshift(x1. n11 = n1.ndl). x3 = round((rand(1. y1diff = max(abs(y11 .dl. x3 = round((rand(1.x23.n0. [x13. % Distributive property [y1.-10.n12] = stepseq(-5. [y2. [y3.30).x3.1)*5).delta(n .n3.5).y1.9 .n2.n23] = stepseq(20.21)*2 . [x23. x11 = cos(pi*n1 / 4). n2 = 0:25. [y22.^ -n2. x2 = x21.^ -n2. x21 = 0. x21 = 0.ny4] = sigadd(y2.ny1] = conv_m(x1.*x24.n1.25).ndl).ny2] = conv_m(x1.n12. ny2diff = max(abs(ny21 .-10.30). ydiff = max(abs(y1 .n22] = stepseq(0.n0)) = x(n .30). 0000 6.nx12] = stepseq(6.nx12). h = 2 * (h11 . [x12.n2). [x11. n y = 2 -6 11 -8 7 -7 9 -4 7 -8 6 n = -4 -3 -2 -1 0 1 2 3 4 5 6 2.n2).-x12. h=h11-h12.7). y = 1 -1 -5 2 3 -5 1 4 n = -6 -5 -4 -3 -2 -1 0 1 -3 4].nh12] = stepseq(5. 3. 1.n] = conv_m(x.nx12] = stepseq(4.2500 85. −3.* x13.2500 21.5000 7.0000 7. h(n) = {1.5). x(n) = n/4[u(n) − u(n − 6)]. [h11.0000 4. n.5).2500 85. [h12.nx12).4).n2).0000 5. h = [1 -1 1 -1 1]. x14 = n1/4.-2.0000 64.nh11] = stepseq(-2.h.nx11.0.nx11] = stepseq(-1.0000 84.nx11] = stepseq(0.0. y. h(n) = 2[u(n + 2) − u(n − 3)]: Matlab script: n1 = 0:7.0.15 Convolutions using conv_m function. y. n2 = -1:3. x = [1 1 0 1 1]. −2.nh12] = stepseq(3.5000 0 0 0 0 n = -3 -2 -1 0 1 2 3 4 5 6 7 8 9 10 11 . y = 0 0 0. [x13. h(n) = {1. n2 = 0:6. x(n) = (1/4)−n [u(n + 1) − u(n − 4)]. −1.n1. x = x14 . h(n) = u(n) − u(n − 5): Matlab script: n1 = -2:5.-x12. [x11.0000 0 0 0 0 n = -2 -1 0 1 2 3 4 5 6 7 8 9 10 11 4.n13] = sigadd(x11. y.^ -n1.n] = conv_m(x. [y.0. [x13.5000 3.nh11] = stepseq(0.2500 1. x(n) = {1. n. 5. y.-3.h. n.n1.4).25 . 4}: Matlab script: ↑ ↑ n1 = -3:3.2500 5. h = [1 -2 [y.h.nx11. 0. x14 = 0. x(n) = {2. [y.5000 1. 1}. y = 0 0.7). [h12.n1.n1.n2). n14 = n1. x = x14 .n] = conv_m(x.h. 1. −4.h12). 6}.6).-2.6).5000 2. −1.n13] = sigadd(x11. [y. x = [2 -4 5 3 -1 -2 6]. 1. [h11. n2 = -3:4. 1}: Matlab script: ↑ ↑ n1 = -3:3. 1. n14 = n1.* x13.50 Solutions Manual for DSP using Matlab (2nd Edition) 2006 P2. [x12.-3.0000 80.n] = conv_m(x. 3. n2 = -3:0. −2. −1. 8).0. xlabel(’n’).9) (0.3).7 −k # " n  # X 9 k − u(n) = (0.8) k=0 0. y2 = conv(h2. Hs3 = stem(n. h = (-0.3.^(n+1))/(0.x).2006 Solutions Manual for DSP using Matlab (2nd Edition) 51 P2.9). %ylabel(’y(n)’).’filled’).8)n u(n).2).8n+1 − (−0. Hs1 = stem(n.’P0216’).8)n−k u(n − k) k=0 k n (−0. title(’Analytical’). subplot(1. . set(Hs2. h2 = h(1:26). xlabel(’n’). Convolution y(n) = h(n) ∗ x(n): y(n) = = ∞ X k=−∞ " n X ∞ X h(k)x(n − k) = (−0.[1.’markersize’.9).y2. xlabel(’n’). ylabel(’y(n)’). x = 0.’markersize’.2).8+0. In the filter function approach of 2.32. To use the Matlab’s filter function we have to represent the h (n) sequence by coefficients an equivalent difference equation. set(Hs3. subplot(1.8.16 Let x(n) = (0. The plots of this solution are shown in Figure 2. 3. %ylabel(’y(n)’). Therefore.x2). The truncated-sequence computation in 3 is correct up to the first 26 samples and then it degrades rapidly. and y(n) = h(n) ∗ x(n).2). the filter solution should be exact except that it is evaluated up to the length of the input sequence. set(Hs1.(-0.8) (0. Hs2 = stem(n. Hf_1 = figure.’off’. 2.9)k (0.3.9)n u(n).^(n+1) . The analytical solution to the convolution in 1 is the exact answer. title(’Using conv function’).’NumberTitle’.y3. n = [0:50]. 1. Computation using convolution of truncated sequences: Matlab script % (b) Plot using the conv function and truncated sequences x2 = x(1:26). close all.9)n+1 = 1.run defaultsettings.’filled’).’markersize’.9). Matlab script: % (c) Plot of the convolution using the filter function y3 = filter([1].3.y1. title(’Using filter function’).8) u(n) 8 k=0 n Matlab script: clc. the infinite-duration sequence x(n) is exactly represented by coefficients of an equivalent filter. % (a) Plot of the analytical convolution y1 = ((0.1).’filled’).^n. h(n) = (−0. subplot(1. set(Hf_1.9].^n.2).’Name’. 32: Problem P2.4 0.2 0 0 0 y(n) 1.2 0 50 n −0.4 0.2 0 50 0 n Figure 2.Solutions Manual for DSP using Matlab (2nd Edition) 52 Analytical Using conv function 2006 Using filter function 1.6 0.2 −0.4 0.2 0.8 0.6 0.2 1.2 −0.2 1 1 1 0.16 convolution plots 50 n .6 0.8 0.2 0.8 0. 70. 5} and h (n) = {6. Such a matrix is called a Toeplitz matrix. Consider the sequences x (n) = {1. 94.2006 Solutions Manual for DSP using Matlab (2nd Edition) 53 P2. 8. It is characterized by the following property [H]i. . j = [H]i− j which is similar to the definition of time-invariance. The linear convolution of the above two sequences is y (n) = {6. The vector representation of the above operation is:             | 6 19 40 70 100 94 76 45 {z y   } |           =           6 7 8 9 0 0 0 0 0 6 7 8 9 0 0 0 0 0 6 7 8 9 0 0 {z 0 0 0 6 7 8 9 0 H 0 0 0 0 6 7 8 9     1   2     3     4    5  | {z } x } (a) Note that the matrix H has an interesting structure. 40. (b) Note carefully that the first column of H contains the impulse response vector h (n) followed by number of zeros equal to the number of x (n) values minus one. 9} 1. The first row contains the first element of h (n) followed by the same number of zeros as in the first column. 4.17 Linear convolution as a matrix-vector multiplication. 19. 3. 76. 45} 2. 2. Using this information and the above property we can generate the whole Topelitz matrix. 7. 100. Each diagonal of H contains the same number. hr).18 Matlab function conv_tp: (a) The Matlab function conv_tp: function [y. hc = [h.5]’.Nx-1)]. 1)].54 Solutions Manual for DSP using Matlab (2nd Edition) P2.9]’.H] = conv_tp(h.x) % y = output sequence in column vector form % H = Toeplitz matrix corresponding to sequence h so that y = Hx % h = Impulse response sequence in column vector form % x = input sequence in column vector form % Nx = length(x). hr = [h(1). Nh = length(h). (b) Matlab verification: x = [1.H]=conv_tp(h. y = y’. y = H*x. h = [6.2. [y. H y = 6 19 40 70 100 94 H = 6 0 0 0 0 7 6 0 0 0 8 7 6 0 0 9 8 7 6 0 0 9 8 7 6 0 0 9 8 7 0 0 0 9 8 0 0 0 0 9 76 45 2006 .x).7.8.zeros(1.H] = conv_tp(h.3. zeros(Nx-1.4.x) % Linear Convolution using Toeplitz Matrix % ---------------------------------------% [y. H = toeplitz(hc. Impulse response 3 2. set(Hs.33. title(’Impulse response’. clc. x = 5*ones(size(n))+3*cos(0.6*pi*n).’off’.’markersize’. y = filter(b. close all.5.a. b = [1 2 0 1].n] = impseq(0.’NumberTitle’.5 0.33: Problem P2. [delta. b = [1 2 0 1].a.5 2 h(n) 1.’filled’).100).’P0219a’).max(n)+5.’Name’. 55 . print -deps2 . xlabel(’n’.max(h)+0.6π n)] u(n): % P0219c: Output response of a system using the filter function.2*pi*n)+4*sin(0. a = [1 -0. n = 0:200.5 1 0.2006 Solutions Manual for DSP using Matlab (2nd Edition) P2.LFS).delta). a = [1 -0..TFS).25y(n − 2) = x(n) + 2x(n − 1) + x(n − 3) (a) Impulse response using the Using the filter function. h = filter(b.25].min(h)-0. Hs = stem(n.0.2).x).’FontSize’.5 0 10 20 30 40 50 60 70 80 90 100 n Figure 2.h.5]).33 the system is stable. axis([min(n)-5.5 0 −0. The plots of the impulse response h(n) is shown in Figure 2.19.’FontSize’. (c) Response y(n) when the input is x(n) = [5 + 3 cos(0. Hf_1 = figure.19 A linear and time-invariant system is described by the difference equation y(n) − 0.25].eps.2π n) + 4 sin(0.1 impulse response plot (b) Clearly from Figure 2.’FontSize’. set(Hf_1. close all.5 0. ylabel(’h(n)’./EPSFILES/P0219a.5y(n − 1) + 0.LFS). % P0219a: System response using the filter function clc. 19. Hs = stem(n. set(Hs.y. print -deps2 .3 response plot 180 200 .’FontSize’./EPSFILES/P0219c.’filled’).’Name’. The plots of the response y(n) is shown in Figure 2.Solutions Manual for DSP using Matlab (2nd Edition) 2006 Hf_1 = figure. xlabel(’n’.LFS).’FontSize’.34: Problem P2.LFS). set(Hf_1. ylabel(’y(n)’.’markersize’.’off’.TFS).2). title(’Output response’.’FontSize’.eps..0.34. Output response 50 45 40 35 30 y(n) 56 25 20 15 10 5 0 0 20 40 60 80 100 120 140 160 n Figure 2.’NumberTitle’.’P0219c’).50]). axis([-10.210. 23.22).LFS).2006 Solutions Manual for DSP using Matlab (2nd Edition) P2.TFS).’YTickMode’.’NumberTitle’. ytick = [-6:6]. Hf_1 = figure.20 A “simple” digital differentiator: y(n) = x(n) − x(n − 1) (a) Response to a rectangular pulse x(n) = 5 [u(n) − u(n − 20)]: % P0220a: Simple Differentiator response to a rectangular pulse clc.a.LFS). a = 1. [x12.’Name’.. set(gca. axis([-1.’FontSize’.x12). xlabel(’n’. set(Hf_1.eps. ylabel(’y(n)’. Output response for rectangular pulse 6 5 4 3 2 y(n) 1 0 −1 −2 −3 −4 −5 −6 0 5 10 15 n Figure 2.0. Hs = stem(n1.’YTick’.35: Problem P2. title(’Output response for rectangular pulse ’.’manual’. close all.-6.’FontSize’.20. set(Hs. b = [1 -1]. x1 = 5*(x11 .’FontSize’.x1)./EPSFILES/P0220a. y1 = filter(b.nx12] = stepseq(20.6]).’off’.’filled’).1 response plot 20 57 .’P0220a’). print -deps2 .22).’markersize’.ytick).35.2). The plots of the response y(n) is shown in Figure 2.0.nx11] = stepseq(0. n1 = 0:22.y1. [x11. 5 0 −0.0.Solutions Manual for DSP using Matlab (2nd Edition) 58 2006 (b) Response to a triangular pulse x(n) = n [u(n) − u(n − 10)] + (20 − n) [u(n − 10) − u(n − 20)]: % P0220b: Simple Differentiator response to a triangular pulse clc. ylabel(’y(n)’.20.LFS).x12) + (20 . set(Hs.2).y2.’Name’. Hf_1 = figure.0. [x12.5]). [x13.max(n2)+1.21).36. print -deps2 .5 1 y(n) 0.’P0220b’).’FontSize’.*(x12 . y2 = filter(b.TFS).36: Problem P2. a = 1.2 response plot 18 20 22 . Output response for triangular pulse 1.min(y2)-0.’NumberTitle’. set(Hf_1.max(y2) + 0. b = [1 -1].nx12] = stepseq(10.5 0 2 4 6 8 10 12 14 16 n Figure 2. [x11.LFS). x2 = n2. n2 = 0:21.’FontSize’.’off’.nx13] = stepseq(20./EPSFILES/P0220b. close all.a.’filled’).eps. axis([min(n2)-1. The plots of the response y(n) is shown in Figure 2.x13).’FontSize’. Hs = stem(n2.nx11] = stepseq(0.*(x11 ..n2).’markersize’.5 −1 −1. title(’Output response for triangular pulse’.x2).21). xlabel(’n’.0.21).5. ’filled’). Hf_1 = figure. x3 = sin(pi*n3/25).0.’FontSize’..’NumberTitle’.3 response plot 90 100 59 .LFS).05 −0.y3. ytick = [-0.15 0 10 20 30 40 50 60 70 80 n Figure 2.15]).’YTick’.’markersize’. title(’Output response for sinusoidal pulse’.0.’FontSize’. ylabel(’y(n)’.-0. The plots of the response y(n) is shown in Figure 2. set(gca.15 0. set(Hs. b = [1 -1].TFS).15].eps.15.1 y(n) 0. axis([-5.1 −0.05:0.2006 Solutions Manual for DSP using Matlab (2nd Edition) (c) Response to a sinusoidal pulse x(n) = sin πn  25 [u(n) − u(n − 100)]: % P0220cSimple Differentiator response to a sinusoidal pulse clc.105.’manual’.’Name’.101). n3 = 0:101.a.101). print -deps2 . a = 1. [x11.’FontSize’.05 0 −0.*x13.37.nx11] = stepseq(0.’YTickMode’.’off’. xlabel(’n’. Output response for sinusoidal pulse 0. set(Hf_1.2). x13 = x11-x12.37: Problem P2. [x12.ytick).’P0220c’).LFS). close all.0./EPSFILES/P0220c.nx12] = stepseq(100. y3 = filter(b.20.x3). Hs = stem(n3.15:0. 60 Solutions Manual for DSP using Matlab (2nd Edition) 2006 . 61 .n.Chapter 3 Discrete-Time Fourier Transform P3.w) function [X] = dtft(x.1 Matlab Function [X] = dtft(x.n.w) % % X = DTFT values computed at w frequencies % x = finite duration sequence over n (row vector) % n = sample position row vector % w = frequency row vector X = x*exp(-j*n’*w).w) % Computes Discrete-time Fourier Transform % [X] = dtft(x.n. x(n) = (0.n13] = sigadd(x11.-180.TFS).’Name’.11).FNTSZ.11).6 −0.5].2 0 ω/π 0.wtick). set(gca.2 0 ω/π 0.wtick).6 −0.’LineWidth’.FNTSZ. phaX1 = angle(X1).8 −0.’YTick’.’XTick’. set(gca.5 1 0.5 4 3.180]). ylabel(’|X|’. |X| Magnitude response 4. xlabel(’\omega/\pi’. xlabel(’\omega/\pi’.1.^ abs(n1)).’P0301a’). set(gca.FNTSZ.1.LFS). ylabel(’Degrees’.1: Problem P3.8 −0.1).201).5 3 2.’off’.5 0 −1 −0.FNTSZ.’LineWidth’.magX1.5]).8 1 Phase Response Degrees 180 0 −180 −1 −0. plot(w1/pi.Solutions Manual for DSP using Matlab (2nd Edition) 62 2006 1.1.n11.TFS).1 DTFT plots .4 0.-11. axis([-1 1 0 4.6 0. The magnitude and phase plots of X (e j ω ) are shown in Figure 3.w1).6 ^ |n|*(u(n+10)-u(n-11)) clc.2 Figure 3. x1 = (0.n1. n1 = n13.phaX1*180/pi.phatick).1. title(’Phase Response’.-11.6 . % P0301a: DTFT of x1(n) = 0. % Hf_1 = figure. phatick = [-180 0 180]. title(’Magnitude response’.1.magtick).LFS).5). [x13.2 0.2:1].’XTick’. w1 = linspace(-pi.n12).-x12. % [x11. magtick = [0:0. subplot(2. close all.*x13. axis([-1. subplot(2.LFS).FNTSZ.4 0. magX1 = abs(X1).6)|n| [u(n + 10) − u(n − 11)]. print -deps2 .4 −0.5).2). wtick = [-1:0. [x12. set(gca.LFS). plot(w1/pi.5 2 1.n11] = stepseq(-10. set(Hf_1.’NumberTitle’.n12] = stepseq(11.’YTick’.1.8 1 0./EPSFILES/P0301a.FNTSZ.6 0.5:4. X1 = dtft(x1.pi..1.4 −0. 2: Problem P3.200]).n21. X2 = dtft(x2.4 0.wtick).TFS). ylabel(’|X|’.6 −0. xlabel(’\omega/\pi’.’XTick’.phaX2*180/pi. phatick = [-180:60:180].4 0. set(gca.0.1.FNTSZ.’off’. x2 = n2.5).FNTSZ.6 −0. print -deps2 .’XTick’.pi. The magnitude and phase plots of X (e j ω ) are shown in Figure 3.1.’LineWidth’.phatick).1. % Hf_1 = figure. set(gca.n21] = stepseq(0.FNTSZ.w2).22).*(0.FNTSZ.22).-x22.2:1].n23] = sigadd(x21.FNTSZ. ylabel(’Degrees’.9)n [u(n) − u(n − 21)].8 −0. |X| Magnitude response 60 50 40 30 20 10 0 −1 −0. plot(w2/pi.wtick). % P0301b: % DTFT of x2(n) = n.2 0 ω/π 0. magX2 = abs(X2).2 0 ω/π 0.LFS).TFS).n22] = stepseq(21.^ n2).0. magtick = [0:10:60].*(u(n)-u(n-21)) clc. [x22.8 1 Degrees Phase Response 180 120 60 0 −60 −120 −180 −1 −0. title(’Magnitude response’.-200.’YTick’. xlabel(’\omega/\pi’.*(0. x(n) = n(0. set(Hf_1.2006 Solutions Manual for DSP using Matlab (2nd Edition) 63 2./EPSFILES/P0301b.5).’LineWidth’.magX2. n2 = n23.2. phaX2 = angle(X2).’YTick’. wtick = [-1:0.2).’NumberTitle’. set(gca.FNTSZ.4 −0.1. axis([-1.1.2 0.LFS).9 ^ n) .8 1 0.*x23.201).LFS).n2. subplot(2..4 −0. plot(w2/pi.magtick).9 .’P0301b’).1. set(gca. title(’Phase Response’. % [x21.8 −0.’Name’. [x23. subplot(2.n22).6 0. close all.2 DTFT plots . w2 = linspace(-pi.1).2 Figure 3.6 0.LFS). [x33.5π n)] [u(n) − u(n − 51)]. xlabel(’\omega/\pi’.8 1 0.0.magX3.LFS).LFS).’P0301c’). w3 = linspace(-pi.2 0 ω/π 0.2.52).magtick).8 1 Degrees Phase Response 180 120 60 0 −60 −120 −180 −1 −0.1). xlabel(’\omega/\pi’. phaX3 = angle(X3). title(’Phase Response’.6 0. |X| Magnitude response 60 50 40 30 20 10 0 −1 −0.3.6 −0.5π n) + j sin(0.6 0. wtick = [-1:0.2:1]. print -deps2 .. set(gca.*x33.4 −0. X3 = dtft(x3.Solutions Manual for DSP using Matlab (2nd Edition) 64 2006 3.2 Figure 3.n3. set(gca.200]).’XTick’.4 −0. x(n) = [cos(0.5*pi*n)).2 0 ω/π 0.LFS).-x32.1.*(u(n)-u(n-51)) clc. [x32. ylabel(’Degrees’.5).pi.8 −0.phaX3*180/pi).’LineWidth’. phatick = [-180:60:180].TFS). ylabel(’|X|’.w3).6 −0.wtick).FNTSZ.n33] = sigadd(x31.5*pi*n3)).201).LFS).FNTSZ.-200.n32] = stepseq(51.4 0. plot(w3/pi. title(’Magnitude response’.1.FNTSZ.5*pi*n)+j*sin(0.2 0.n31] = stepseq(0.4 0.FNTSZ.3: Problem P3.’NumberTitle’.’Name’.FNTSZ.’LineWidth’. % Hf_1 = figure.’XTick’. set(gca. plot(w3/pi.1. subplot(2.wtick).1.’YTick’. magtick = [0:10:60].52). set(gca. The magnitude and phase plots of X (e j ω ) are shown in Figure 3.’YTick’. x3 = (cos(0.3 DTFT plots .8 −0. n3 = n33.n31.5). subplot(2.phatick). close all.5*pi*n3)+j*sin(0. axis([-1.n32).FNTSZ.1. magX3 = abs(X3).1. set(Hf_1. % [x31./EPSFILES/P0301c.’off’.0. % P0301c: % DTFT of x3(n) = (cos(0.TFS). ylabel(’Degrees’.4 −0. plot(w4/pi.8 1 Degrees Phase Response 180 120 60 0 −60 −120 −180 −1 −0. % Hf_1 = figure.’YTick’.4: Problem P3.2006 Solutions Manual for DSP using Matlab (2nd Edition) 65 4.LFS). 1.2:1]. 1. n = 0:7. wtick = [-1:0.5).6 0. close all. 4}. magtick = [0:5:25].n4. n4 = [0:7]. X4 = dtft(x4.25]).4 −0.FNTSZ.FNTSZ.FNTSZ. x(n) = {4.8 −0.FNTSZ. title(’Phase Response’. title(’Magnitude response’.phatick). 2. set(Hf_1.1.6 −0. 3.’LineWidth’.. phaX4 = angle(X4).phaX4*180/pi.LFS).TFS).2).1. set(gca. axis([-1. subplot(2. set(gca. axis([-1.1.8 −0. magX4 = abs(X4).LFS). clc.magX4.5).4.w4).FNTSZ.1.’YTick’.LFS).2 0 ω/π 0. xlabel(’\omega/\pi’.6 0.1.-200.’NumberTitle’. Magnitude response 25 |X| 20 15 10 5 0 −1 −0. set(gca.4 0. % x4 = [4 3 2 1 1 2 3 4]. ylabel(’|X|’.0. set(gca. 2.FNTSZ. subplot(2. ↑ % P0301d: % DTFT of x4(n) = [4 3 2 1 1 2 3 4] .’Name’.8 1 0.’XTick’.4 DTFT plots .’XTick’. xlabel(’\omega/\pi’.2 0. 3. The magnitude and phase plots of X (e j ω ) are shown in Figure 3.wtick).2 0 ω/π 0.201).’off’.1. plot(w4/pi.200]).pi.TFS). phatick = [-180:60:180].6 −0.’LineWidth’.1.magtick).’P0301d’).4 0.1).wtick). w4 = linspace(-pi.2 Figure 3. print -deps2 ./EPSFILES/P0301d. 2.wtick). subplot(2.phaX5*180/pi.LFS). wtick = [-1:0. plot(w5/pi.6 −0. n = 0:7.FNTSZ.LFS).’YTick’.5. −4}.pi.FNTSZ./EPSFILES/P0301e.FNTSZ. axis([-1 1 0 20]).FNTSZ.5).6 0.2 0 ω/π 0.1.FNTSZ.’LineWidth’.2 Figure 3.LFS).2). −2.200]). Magnitude response 20 |X| 15 10 5 0 −1 −0.TFS). title(’Magnitude response’.magtick).’off’. set(gca.5). clc. ylabel(’|X|’. subplot(2.’LineWidth’.-200. xlabel(’\omega/\pi’. xlabel(’\omega/\pi’.’XTick’. title(’Phase Response’. ylabel(’Degrees’. 3.n5.’P0301e’). −1.’Name’. X5 = dtft(x5.1).8 −0.4 −0. close all.8 1 0.4 0. phaX5 = angle(X5).. magX5 = abs(X5). −3.1. ↑ % P0301e: % DTFT of x5(n) = [4 3 2 1 -1 -2 -3 -4] . set(gca.’XTick’.6 −0.4 0.4 −0.8 −0.FNTSZ.1. plot(w5/pi. n5 = [0:7].LFS).2 0. phatick = [-180:60:180].1. set(Hf_1.’NumberTitle’.w5).’YTick’. set(gca. magtick = [0:5:20]. % Hf_1 = figure.201).1.1. x(n) = {4. % x5 = [4 3 2 1 -1 -2 -3 -4].magX5.2:1].5: Problem P3.6 0.2 0 ω/π 0.Solutions Manual for DSP using Matlab (2nd Edition) 66 2006 5. The magnitude and phase plots of X (e j ω ) are shown in Figure 3. set(gca. 1.wtick).8 1 Degrees Phase Response 180 120 60 0 −60 −120 −180 −1 −0. print -deps2 .5 DTFT plots . axis([-1.phatick).TFS). w5 = linspace(-pi. x2 = [x1 x1]. title([’Magnitude response’ char(10) ’signal x_1’].pi.n = [0:3].FNTSZ. title([’Magnitude response’ char(10) ’signal x_2’].1.  x1 (n).2 Let x1 (n) = {1.’LineWidth’.FNTSZ.phatick).FNTSZ.magX1.TFS).TFS).TFS). xlabel(’\omega/\pi’. Matlab Verification: % P0302b: x1(n) = [1 2 2 1]. A new sequence x2 (n) is formed using ↑  0 ≤ n ≤ 3. clc. w2 = linspace(-pi.phaX2*180/pi. set(gca.magtick2).’LineWidth’.1) 1. set(gca.’XTick’.1.TFS).wtick). phaX2 = angle(X2).2. ylabel(’Degrees’. X2 = dtft(x2.’off’./EPSFILES/P0302b. 2.FNTSZ.LFS).’YTick’. plot(w2/pi.2.FNTSZ.LFS).  1 0.phaX1*180/pi.’LineWidth’.’P0302b’). ylabel(’|X_1|’.FNTSZ.5). Otherwise.LFS).4). xlabel(’\omega/\pi’.magtick1). magtick1 = [0:2:8].1.5). subplot(2.1).w2). close all. phaX1 = angle(X1). xlabel(’\omega/\pi’. plot(w2/pi. axis([-1 1 0 16]). n2 = [0:7]. set(Hf_1.’YTick’. set(gca. plot(w2/pi.’YTick’. 1}. set(gca..FNTSZ.phatick). ylabel(’|X_2|’.2. magX2 = abs(X2). phatick = [-180:60 :180].wtick).wtick). (3.n = [4:7].LFS).LFS). Hf_1 = figure. ylabel(’Degrees’. magX1 = abs(X1).FNTSZ. set(gca. . xlabel(’\omega/\pi’. % x2(n) = x1(n) .FNTSZ. x1 = [1 2 2 1]. Clearly.LFS).w2).n2.’Name’. 2. 2.magX2. plot(w2/pi. axis([-1 1 0 8]). subplot(2.’YTick’. set(gca.’XTick’. magtick2 = [0:4:16]. set(gca. x2 (n) = x (n − 4). subplot(2. wtick = [-1:0.n1.LFS).1.5:1].FNTSZ.2). title([’Phase response’ char(10) ’signal x_1’]. Hence X 2 (e j ω ) = X 1 (e j ω ) + X 1 (e j ω )e− j 4ω = 2e− j 2ω cos(2ω)X 1 (e j ω ) Thus the magnitude |X 1 (e j ω )| is scaled by 2 and changed by | cos(2ω)| while the phase of |X 1 (e j ω )| is changed by 2ω.’XTick’. n1 = [0:3].5).wtick).’XTick’.’NumberTitle’.n = [0:3].’LineWidth’. X1 = dtft(x1.3). subplot(2.201). % = x1(n-4) .LFS).FNTSZ.2. 4 ≤ n ≤ 7. print -deps2 . set(gca. title([’Phase response’ char(10) ’signal x_2’].2006 Solutions Manual for DSP using Matlab (2nd Edition) 67 P3. x2 (n) = x1 (n) + x1 (n − 4). axis([-1 1 -200 200]).FNTSZ.5). axis([-1 1 -200 200]). Magnitude response signal x Magnitude response signal x 2 |X2| |X1| 1 8 6 4 2 0 −1 −0.5 1 180 120 60 0 −60 −120 −180 −1 −0.5 0 ω/π 0.2 DTFT plots 0.5 1 16 12 8 4 0 −1 180 120 60 0 −60 −120 −180 −1 −0.5 1 .5 0 ω/π 0.6 which confirms the observation in part 1.5 1 Phase response signal x2 Degrees Degrees Phase response signal x1 −0. above.5 0 ω/π 0.2.Solutions Manual for DSP using Matlab (2nd Edition) 68 2006 The magnitude and phase plots of X 1 (e j ω ) and X 2 (e j ω ) are shown in Figure 3.6: Problem P3.5 0 ω/π Figure 3. 5n e− j nω = 8 e j 2ω 1 − 0.FNTSZ.’XTick’. subplot(2. ylabel(’|X|’. The magnitude and phase plots of X (e j ω ) are shown in Figure 3.FNTSZ.8 1 0. set(gca.2:1].2006 Solutions Manual for DSP using Matlab (2nd Edition) 69 P3.1.TFS).3 Analytical computation of the DTFTs and plotting of their magnitudes and angles.1.pi.5)^n)*u(n+2) = 8*exp(j*2*w)/(1-0.2).0.’LineWidth’.’NumberTitle’. X1 = 8*exp(j*2*w1)..5) e ∞ X 0 0.LFS). w1 = linspace(0. close all.5 e −2 −2 j 2ω = 2(0.4 ω/π 0.7: Problem P3.5*exp(-j*w)) clc.TFS).’LineWidth’.’Name’.5)n u(n + 2).1.501).’YTick’.magX1. axis([0.LFS). wtick = [0:0.LFS).4 ω/π 0. set(gca.5*exp(-j*w1)).6 0. x(n) = 2 (0.1.1. title(’Phase Response’.wtick).7. 1.’XTick’./(1-0.5e− j ω Matlab Verification: % P0303a: DTFT of x1(n) = 2*((0.wtick). magX1 = abs(X1).2 0.1).FNTSZ. xlabel(’\omega/\pi’.’P0303a’).5).5 u(n + 2)e − j nω =2 ∞ X n − j nω 0.-200. xlabel(’\omega/\pi’. phatick = [-180:60:180].magtick).1 DTFT plots . set(gca. X e jω  =2 ∞ X −∞ n 0.5).3.LFS). subplot(2. title(’Magnitude response’./EPSFILES/P0303a. axis([0.FNTSZ.phatick).2 0.8 1 Degrees Phase Response 180 120 60 0 −60 −120 −180 0 0.20]). Magnitude response 20 |X| 16 12 8 4 0 0 0.6 Figure 3. set(gca. magtick = [0:4:20]. phaX1 = angle(X1). plot(w1/pi.200]).1. set(Hf_1. ylabel(’Degrees’. plot(w1/pi.’YTick’.FNTSZ.FNTSZ. print -deps2 .phaX1*180/pi.’off’. Hf_1 = figure. 1. Magnitude response 5 |X| 4 3 2 1 0 0 0.wtick). phatick = [-180:60:180].1).0.LFS). axis([0.2 0.’FontSize’.TFS). xlabel(’\omega/\pi’.6)11 cos(11ω) + 2(0.6)12 cos(10ω) 1. magX2 = abs(X2).magX2.6n e− j nω − 1 = 0.TFS).-200. subplot(2.’FontSize’. magtick = [0:1:5]. close all. x(n) = (0. Hf_1 = figure.’XTick’. ylabel(’Degrees’.1.’FontSize’.200]). plot(w2/pi.wtick).pi.Solutions Manual for DSP using Matlab (2nd Edition) 70 2006 2.’YTick’. set(Hf_1.2:1]. wtick = [0:0.6) [u(n + 10) − u(n − 11)] e = 0.2 DTFT plots . print -deps2 .2 cos(ω) Matlab Verification: % P0303b: DTFT of x2(n) = (0.8 1 0.64-2*(0.1.36 − 1.phatick). w2 = linspace(0.8. X2 = (0.8: Problem P3. xlabel(’\omega/\pi’.501).2). axis([0.8 1 Degrees Phase Response 180 120 60 0 −60 −120 −180 0 0. title(’Phase Response’. ylabel(’|X|’.phaX2*180/pi.’P0303b’). set(gca.’LineWidth’. plot(w2/pi.LFS).6−n e− j nω + 10 X 0 −10 0./(1.1. set(gca.4 ω/π 0.’XTick’.6)^11*cos(11*w2)+2*(0. X e jω  ∞ 10 X X |n| − j nω = (0.5).6|n| e− j nω −∞ = 0 X −10 0.. title(’Magnitude response’.1.’NumberTitle’. The magnitude and phase plots of X (e j ω ) are shown in Figure 3. phaX2 = angle(X2).2*cos(w2)).LFS).6) ^ |n|*[u(n+10)-u(n-11)] clc.magtick).’FontSize’.4 ω/π 0.’Name’.’FontSize’.64 − 2(0.’YTick’.’FontSize’.’off’.LFS).2 0.’LineWidth’.3.1. subplot(2.5).6 Figure 3.6)|n| [u(n + 10) − u(n − 11)]. set(gca.36-1. set(gca.6 0.6)^12*cos(10*w2))./EPSFILES/P0303b.5]). ’YTick’.’XTick’. plot(w3/pi.’P0303c’). set(gca. X3 = X3_num.9e− j ω −4.’FontSize’.2:1].’YTick’.1.9) e −1 j 1ω − (0.’off’.LFS). X3_den = 1-1.TFS). Hf_1 = figure. ylabel(’Degrees’.1.9) ^ n)*u(n+3).wtick). set(gca.9e− j ω )2 1 − 1.9)n e− j nω 0 0.9)n u(n + 3)e− j nω = n (0. close all./X3_den./EPSFILES/P0303c.2006 Solutions Manual for DSP using Matlab (2nd Edition) 71 3.8 1 0. title(’Phase Response’.3 DTFT plots .9.8 1 Degrees Phase Response 180 120 60 0 −60 −120 −180 0 0. ylabel(’|X|’.’NumberTitle’.4 ω/π 0.. x(n) = n (0. magX3 = abs(X3).1151e j 3ω + 4.100]). xlabel(’\omega/\pi’. axis([0.wtick).1151*exp(j*3*w3)+4.9383*exp(j*2*w3)).6 Figure 3.2 0. subplot(2.8*exp(-j*w3)+0.6 0.magtick).’XTick’.’FontSize’.’Name’.1. plot(w3/pi. Magnitude response 100 |X| 80 60 40 20 0 0 0.1.1).1111e j ω + + ∞ X n (0. print -deps2 .LFS). phatick = [-180:60:180]. xlabel(’\omega/\pi’.4691e j 2ω − 1. title(’Magnitude response’.LFS).3. phaX3 = angle(X3). set(gca.9) e = −4. magtick = [0:20:100].0.9)n u(n + 3).5).1.LFS).’FontSize’. X3_num = (-4.81*exp(-j*2*w3).magX3.’LineWidth’.4 ω/π 0.9383e j 2ω = (1 − 0.1. clc.5).2). set(Hf_1.pi. The magnitude and phase plots of X (e j ω ) are shown in Figure 3.1152e j 3ω − 2. axis([0.phatick).8e− j ω + 0.81e− j 2ω Matlab Verification: % P0303c: DTFT of x3(n) = n*((0. set(gca.’FontSize’.TFS).’FontSize’. ∞ ∞ X  X X e jω = n (0.9: Problem P3.-200.’FontSize’.2 0. subplot(2.501). w3 = linspace(0.phaX3*180/pi.9)n e− j nω −∞ −3 −3 j 3ω = −3(0.’LineWidth’.200]).9) e −2 j 2ω − 2(0. wtick = [0:0. 3.6 Figure 3.LFS).’Name’.56e− j 3ω 4e 4e = 1 − 0. X4 = X4_num.magtick).’FontSize’.8 1 Degrees Phase Response 180 120 60 0 −60 −120 −180 0 0. plot(w4/pi.8)n−1 u(n − 2).1.’YTick’.64e ∞ X 0 − j 3ω 1 − 0.8)n e− j nω + 4e− j 2ω 2 + − j 2ω −∞ ∞ X (0. set(gca.1.TFS). X4_den = 1-1.200]).5).8)n−1 u(n − 2)e− j nω = (n + 5) (0.8)e− j 2ω = 0.pi. phaX4 = angle(X4). ylabel(’Degrees’.1.-200. set(Hf_1.’LineWidth’.4 ω/π 0. subplot(2.’FontSize’.2 0. set(gca.Solutions Manual for DSP using Matlab (2nd Edition) 72 4.10.’NumberTitle’. set(gca. ∞ ∞ X  X X e jω = (n + 3) (0. X4_num = 4*exp(-2*j*w4)-2.wtick).’XTick’. clc. ylabel(’|X|’. title(’Phase Response’. print -deps2 .2).8 1 0.4 DTFT plots .2 0. The magnitude and phase plots of X (e j ω ) are shown in Figure 3.’LineWidth’.LFS).8e− j ω 1 − 1. xlabel(’\omega/\pi’.’FontSize’. |X| Magnitude response 40 35 30 25 20 15 10 5 0 0 0.magX4.2:1]. magtick = [0:5:40].’XTick’. wtick = [0:0. title(’Magnitude response’. phatick = [-180:60:180].’P0303d’).’FontSize’.LFS).10: Problem P3.501).TFS). subplot(2. w4 = linspace(0. x(n) = P∞ −∞ 2006 (n + 3) (0.8)n e− j nω 0 − j 2ω − 2.8) ^ (n-1))*u(n-2). close all. axis([0 1 0 40]).LFS). set(gca.phaX4*180/pi. Hf_1 = figure.8e− j ω n(0.64*exp(-2*j*w4).6*exp(-1*j*w4)+0.6 0.4 ω/π 0.wtick).1)./EPSFILES/P0303d.’FontSize’./X4_den.64e− j 2ω Matlab Verification: % P0303d: DTFT of x4(n) = (n+3)*((0. xlabel(’\omega/\pi’.6e− j ω + 0.56*exp(-3*j*w4).’off’..’YTick’. plot(w4/pi.8)n+1 u(n)e− j (n+2)ω −∞ = (0.phatick).’FontSize’. axis([0.5).1. magX4 = abs(X4).1. plot(w5/pi.49*exp(-j*2*w5).1./EPSFILES/P0303e.2:1]..phatick).magX5. title(’Phase Response’.4 ω/π 0. phatick = [-180:60:180].2 0.1.phaX5*180/pi. set(Hf_1.7) cos(0. X5 = X51.3.magtick).’FontSize’.wtick).’LineWidth’.200]). w5 = [0:500]*pi/500. subplot(2. ∞ ∞ X  X X e jω = 4 (−0.wtick). title(’Magnitude response’.TFS).1.5 DTFT plots .25*pi)*exp(-j*w5)+0. plot(w5/pi.1). Magnitude response 10 |X| 8 6 4 2 0 0 0.7)2 e− j 2ω 1 + 1. X52 = ones(size(w5))+1.5).LFS).25π n)u(n).7) ^ n)*cos(0. X51 = 4*(ones(size(w5))+0.’XTick’. x(n) = 4 (−0.LFS).25π n)e− j nω −∞ =4 0 − jω 1 − (−0. Hf_1 = figure. axis([0.4e− j ω + 0.25*pi)*exp(-j*w5)).2006 Solutions Manual for DSP using Matlab (2nd Edition) 73 5. ylabel(’Degrees’.6 0.7*cos(0.4 ω/π 0. wtick = [0:0. magX5 = abs(X5).TFS). set(gca.495e− j ω = 4 1 − 2(−0. print -deps2 . ylabel(’|X|’.’FontSize’.’P0303e’).-200. subplot(2.7)e− j ω + (−0.1.25π n)u(n)e− j nω = 4 (−0. set(gca.’YTick’.’FontSize’. set(gca. phaX5 = angle(X5).25π )e 1 + 0.8 1 0.’LineWidth’.’YTick’.’FontSize’.’Name’.8 1 Degrees Phase Response 180 120 60 0 −60 −120 −180 0 0.LFS).’FontSize’.5).49e− j 2ω Matlab Verification: % P0303e: DTFT of x5(n) = 4*((-0.11: Problem P3. close all.2 0.25*pi*n)*u(n) clc.6 Figure 3.1. axis([0 1 0 10]). set(gca.’FontSize’. magtick = [0:2:10]. xlabel(’\omega/\pi’.7)n cos(0.7)n cos(0.LFS).11. xlabel(’\omega/\pi’. The magnitude and phase plots of X (e j ω ) are shown in Figure 3.2).’off’.’NumberTitle’.4*cos(0.’XTick’.7)n cos(0./X52. w).4).1.1]). magX = abs(X).’YTick’.1]).2). axis([-1 1 0 1. xlabel(’\omega/\pi’. set(gca.5 0 −1 −0.’YTick’.TFS).4 Window function DTFTs: Rectangular Window: R M (n) = u(n) − u(n − M) Matlab script: % P0304a: DTFT of a Rectangular Window. % M = 10 M = 10.5 −0. subplot(2.5 |X| M = 50 1 0. magX = abs(X).501).5 0 ω/π 0.magtick).’XTick’. % M = 101 M = 101. magX = magX/max(magX).5).’FontSize’.’LineWidth’.3).2. X = dtft(x.n. plot(w/pi.LFS).4 Rectangular window DTFT plots 2006 . magX = magX/max(magX).wtick.’XTick’.1].5 1 M = 101 1 0 −1 0 0. plot(w/pi.magtick).25.magX. X = dtft(x.n.5:1.5 1 0 −1 −0. n = 0:M. % M = 50 M = 50. x = ones(1.’LineWidth’.’XTick’. Hf_1 = figure./EPSFILES/P0304a. magX = magX/max(magX). |X| M = 10 M = 25 1 1 0.magX.1).length(n)). n = 0:M. x = ones(1. title([’M = 10’].LFS).101 clc.1]).12: Problem P3.’FontSize’.5 0.5). M = 10.’FontSize’. subplot(2.magX.’FontSize’.2. magX = magX/max(magX).’LineWidth’.wtick.5 0. % M = 25 M = 25. n = 0:M.’FontSize’.5).length(n)). close all. x = ones(1. set(Hf_1. The magnitude plots of the DTFTs are shown in Figure 3.1]). set(gca. axis([-1 1 0 1. axis([-1 1 0 1.5:1].2.TFS). X = dtft(x.1.w).w). plot(w/pi. ylabel(’|X|’.LFS). subplot(2.5 1 0 −1 −0.1.’FontSize’.5 0 0.’Name’.5). magX = abs(X).’P0304a’). axis([-1 1 0 1.TFS). x = ones(1.wtick. subplot(2.’FontSize’. ylabel(’|X|’.’XTick’.50. magtick = [0:0.1. wtick = [-1:0.’NumberTitle’.2. title([’M = 101’]. title([’M = 50’]. plot(w/pi.74 Solutions Manual for DSP using Matlab (2nd Edition) P3. n = 0:M. print -deps2 . set(gca.magX. X = dtft(x.magtick).pi.5 0 ω/π Figure 3.’YTick’. title([’M = 25’]. magX = abs(X).magtick).12.’FontSize’. set(gca.wtick.’off’.5 1 0.’YTick’.n.n. xlabel(’\omega/\pi’.TFS).length(n))..length(n)). w = linspace(-pi.’LineWidth’.LFS).w). title([’M = 25’].LFS).1.TFS). magX = magX/max(magX).magtick).’YTick’. plot(w/pi.’Name’.TFS). n = 0:M. xlabel(’\omega/\pi’. title([’M = 101’].5). wtick = [-1:0.magtick). The magnitude plots of the DTFTs are shown in Figure 3.2).w). xlabel(’\omega/\pi’.5 M = 50 |X| 2006 1 0. w = linspace(-pi. subplot(2.13.5).5 1 M = 101 1 0 −1 0 0. set(gca.TFS). Hf_1 = figure.1]. ylabel(’|X|’.n. magX = magX/max(magX).’FontSize’..13: Problem P3. print -deps2 .’P0304b’).pi.LFS).5).1]).’LineWidth’. n = 0:M./EPSFILES/P0304b. subplot(2. set(Hf_1. set(gca.501). X = dtft(x.wtick. plot(w/pi. X = dtft(x.’FontSize’. x = (1-(abs( M-1-(2*n) )/(M+1)) ). magX = magX/max(magX).1]).wtick.M = 10.1.5 0.w).5:1]. ylabel(’|X|’.5 0 0.101 clc.magtick).1. magX = magX/max(magX).4 Triangular window DTFT plots 75 .25.wtick. % M = 101 M = 101.4). title([’M = 10’].Solutions Manual for DSP using Matlab (2nd Edition)   |M − 1 − 2n| Triangular Window: T M (n) = 1 − R M (n) M −1 Matlab script: % P0304b: DTFT of a Triangular Window.’NumberTitle’. X = dtft(x.5:1.’FontSize’.wtick.n. % M = 25 M = 25.magtick). n = 0:M. % M = 10 M = 10.n.2. axis([-1 1 0 1.LFS). title([’M = 50’]. |X| M = 10 M = 25 1 1 0.’LineWidth’.’FontSize’. plot(w/pi.’YTick’. x = (1-(abs( M-1-(2*n) )/(M+1)) ). n = 0:M.TFS). x = (1-(abs( M-1-(2*n) )/(M+1)) ).’XTick’.’XTick’. magX = abs(X).w).’XTick’. magX = abs(X).’FontSize’. magtick = [0:0.50.magX.1]). set(gca.’off’.1]).2.’YTick’.magX.5 1 0.’XTick’. subplot(2. x = (1-(abs( M-1-(2*n) )/(M+1)) ).’LineWidth’.5 0 −1 −0. magX = abs(X). axis([-1 1 0 1.5 −0. close all.’FontSize’.5 0.5 0 ω/π Figure 3.2.5 1 0 −1 −0.LFS). set(gca.5).’YTick’.5 1 0 −1 −0.’LineWidth’.magX.3). axis([-1 1 0 1. % M = 50 M = 50.1.2. plot(w/pi.n. X = dtft(x.1). subplot(2. magX = abs(X).’FontSize’.w). axis([-1 1 0 1.5 0 ω/π 0.magX.’FontSize’. magX = magX/max(magX). n = 0:M. magX = magX/max(magX).magX.1]). X = dtft(x. set(gca. close all.pi.5).TFS). wtick = [-1:0.’FontSize’.5).wtick. plot(w/pi. plot(w/pi. axis([-1 1 0 1. plot(w/pi. subplot(2. ylabel(’|X|’. set(gca.1]). % M = 50 M = 50. w = linspace(-pi.TFS). set(gca. magX = abs(X).3).wtick.’YTick’.5 0 ω/π Figure 3.5*(1-cos((2*pi*n)/(M-1)) ). x = 0. magX = abs(X).’Name’. plot(w/pi. axis([-1 1 0 1.’XTick’.25.n. magX = abs(X). magtick = [0:0.magX.’FontSize’. magX = magX/max(magX).5*(1-cos((2*pi*n)/(M-1)) ). xlabel(’\omega/\pi’. n = 0:M. subplot(2.5*(1-cos((2*pi*n)/(M-1)) ).’FontSize’.2).TFS).n.’FontSize’.5 M = 50 |X| 76 1 0.4 Hann window DTFT plots 2006 . title([’M = 50’]. subplot(2.’FontSize’.14: Problem P3.5 1 0 −1 −0.2.’NumberTitle’. x = 0. xlabel(’\omega/\pi’. ylabel(’|X|’.’YTick’.1.  |X| M = 10 M = 25 1 1 0.2.w).n.LFS). % M = 10 M = 10. print -deps2 .5 0.5 1 M = 101 1 0 −1 0 0. n = 0:M.TFS).1]).’LineWidth’.magtick).1.’XTick’. x = 0.501).w).’FontSize’. n = 0:M. X = dtft(x.5*(1-cos((2*pi*n)/(M-1)) ).LFS).magtick).’XTick’.wtick.’XTick’.1.’P0304c’).Solutions Manual for DSP using Matlab (2nd Edition)  2π n Hann Window: C M (n) = 0.magtick). set(Hf_1.14.w).5 0 0.M = 10. % M = 25 M = 25.1]).2.LFS). axis([-1 1 0 1.5 −0.5)..5:1.1]. x = 0.5 1 0.5 0 −1 −0.4). title([’M = 101’]. set(gca. magX = abs(X).1). axis([-1 1 0 1. magX = magX/max(magX).w). title([’M = 25’]. X = dtft(x.5).5:1]./EPSFILES/P0304c.2.magtick).101 clc. Hf_1 = figure.5 0 ω/π 0.’YTick’.’LineWidth’.’off’.wtick.’FontSize’. X = dtft(x.’LineWidth’.5 1 0 −1 −0.’FontSize’.5 0. subplot(2. title([’M = 10’].n.magX. % M = 101 M = 101.’YTick’.50. The magnitude plots of the DTFTs are shown in Figure 3.’LineWidth’.1.5 1 − cos R M (n) M −1 Matlab script: % P0304c: DTFT of a Hann Window.LFS).magX. 2.’LineWidth’. Hf_1 = figure.LFS).LFS).501).5).’FontSize’.’FontSize’. title([’M = 10’].’XTick’.46*cos((2*pi*n)/(M-1)) ).n.5 1 M = 101 1 0 −1 0 0.5 0. title([’M = 25’]. print -deps2 . magX = magX/max(magX).1]). X = dtft(x.46*cos((2*pi*n)/(M-1)) ).4).2. magX = magX/max(magX).2). axis([-1 1 0 1. subplot(2. % M = 10 M = 10.’FontSize’.wtick.magX.’FontSize’. ylabel(’|X|’.1].5 0 0.5 1 0 −1 −0.3). % M = 101 M = 101.46*cos((2*pi*n)/(M-1)) ).n.2. X = dtft(x.’LineWidth’.’XTick’. n = 0:M.TFS).54-0. w = linspace(-pi. magtick = [0:0.2. magX = magX/max(magX).’NumberTitle’.’off’. set(gca.magtick).’LineWidth’.5 M = 50 |X| 2006 1 0. plot(w/pi. X = dtft(x. xlabel(’\omega/\pi’.magX.5 1 0. axis([-1 1 0 1.wtick.wtick.5 0 ω/π Figure 3.magtick).54-0.’XTick’.’FontSize’.’LineWidth’.TFS). % M = 25 M = 25.1.’YTick’. set(gca.  |X| M = 10 M = 25 1 1 0. x = (0. magX = abs(X).w).46*cos((2*pi*n)/(M-1)) ).1. X = dtft(x.5:1]. wtick = [-1:0.54-0. title([’M = 101’].w).1]).magtick).magX. subplot(2.’Name’.Solutions Manual for DSP using Matlab (2nd Edition)  2π n Hamming Window: H M (n) = 0. The magnitude plots of the DTFTs are shown in Figure 3.LFS). n = 0:M.15: Problem P3.magtick). set(gca. plot(w/pi.25.5 1 0 −1 −0. magX = abs(X).w).15. x = (0. magX = magX/max(magX).54 − 0.5 0 ω/π 0.5). subplot(2.1. magX = abs(X).magX.1.5). title([’M = 50’].’YTick’.wtick. plot(w/pi.5 −0.5 0 −1 −0.M = 10.5). xlabel(’\omega/\pi’.. % M = 50 M = 50.101 clc. subplot(2./EPSFILES/P0304d. close all. axis([-1 1 0 1.pi.’FontSize’. ylabel(’|X|’.1]).50.’FontSize’. n = 0:M.TFS).5:1.n. magX = abs(X). set(gca.46 cos R M (n) M −1 Matlab script: % P0304d: DTFT of a Hamming Window.LFS). set(Hf_1.’YTick’. n = 0:M. plot(w/pi.4 Hamming window DTFT plots 77 .n.’XTick’.54-0.’P0304d’).1).’FontSize’.5 0.1]). axis([-1 1 0 1.w).’YTick’. x = (0. x = (0.TFS). 1.Solutions Manual for DSP using Matlab (2nd Edition) 78 P3. X e X e jω    e j 5ω + e− j 5ω − j 3ω e j 3ω + e− j 3ω +8 e = 1−6 2 2 = 4e j 2ω − 3 + e− j 3ω − 3e− j 6ω + 4e− j 8ω Hence x(n) = {4. 1. 0. 54 . 1. −2. −3. 54 . 0. ↑  jω 3. 1. −1. 1. 1. − 52 }. X e = 2 + j 4 sin(2ω) − 5 cos(4ω): Using the Euler identity  e j 2ω − e− j 2ω e j 4ω + e− j 4ω X e jω = 2 + j 4 −5 = − 52 e j 4ω + 2e j 2ω + 2 − 2e− j 2ω − 52 e− j 4ω 2j 2 Hence x(n) = {− 52 . 0. ↑  4. 1. ↑  jω = [1 − 6 cos(3ω) + 8 cos(5ω)] e− j 3ω : Using the Euler identity 2. 0. X e j ω = [1 + 2 cos(ω) + 3 cos(2ω)] cos(ω/2)e− j 5ω/2 : Using the Euler identity X e jω   1 1 e j ω + e− j ω e j 2ω + e− j 2ω e j 2 ω + e− j 2 ω − j 5ω/2 = 1+2 +3 e 2 2 2   e− j 2ω + e− j 3ω = 32 e j 2ω + e j ω + 1 + e− j ω + 32 e− j 2ω 2 = 34 + 54 e− j ω + e− j 2ω + e− j 3ω + 54 e− j 4ω + 34 e− j 5ω  Hence x(n) = { 34 . 3. 0. −1. 2. 0. −2}. 0. 34 }. −3.5 Inverse DTFTs using the definition of the DTFT:  1. X e j ω = 3 + 2 cos(ω) + 4 cos(2ω): Using the Euler identity  e j 2ω + e− j 2ω e j ω + e− j ω X e jω = 3 + 2 +4 = 2e j 2ω + e j ω + 3 + e− j ω + 2e− j 2ω 2 2 Hence x(n) = {2. 5. 2. ↑ 2006 . 4}. X e  jω ↑ = j [3 + 2 cos(ω) + 4 cos(2ω)] sin(ω)e− j 3ω : Using the Euler identity X e jω    e j ω + e− j ω e j 2ω + e− j 2ω e j ω − e− j ω − j 3ω = j 3+2 +4 e 2 2 2j = 2 + e− j ω + e− j 2ω − e− j 4ω − e− j 5ω − 2e− j 6ω Hence x(n) = {2. 0. 0. 2}. 0. 0. 2006 Solutions Manual for DSP using Matlab (2nd Edition) 79 P3.6 Inverse DTFTs using the definition of the IDTFT::   1. X e = 0. π/3 < |ω| ≤ π . jω 1. 0 ≤ |ω| ≤ π/3. Solution: Consider  . π/3 Z π Z π/3 n   j nω sin πn 1 1 1 e j nω . . jω j nω 3 X e e dω = e dω = = = sinc x(n) = 2π −π 2π −π/3 j 2π n . Solution: Consider Z π Z −3π/4 Z π  j nω 1 1 1 jω j nω x(n) = X e e dω = e dω + e j nω dω 2π −π 2π −π 2π 3π/4 . 0 ≤ |ω| ≤ 3π/4. 1. 3π/4 < |ω| ≤ π .−π/3 πn 3 3  0. π   Z π . 2 1 sin(nω) . 3 3n = cos(nω) dω = = δ(n) − sinc 2π 3π/4 π n . Solution: Consider " # . X e jω  =    2. 0 ≤ |ω| ≤ π/8. 3π/4 < |ω| ≤ π . π/8 < |ω| ≤ 3π/4. 3.3π/4 4 4 2. jω = 1. X e  0. . Z π/8  Z 3π/4 2 sin(nω) . . π/8 sin(nω) . . 3π/4 1 x(n) = 2 2 cos(nω) dω + cos(nω) dω = + 2π 0 π n . 0 n . 4. 1. −π ≤ ω < π/4. 3π/4 < |ω| ≤ π .π/8 π/8         nπ   nπ   nπ  1 3nπ 1 3nπ = 2 sin + sin − sin = sin + sin nπ 8 4 8 nπ 8 4     1 n 3 3n = sinc + sinc 8 8 4 4   0. X e =  0. Solution: Consider . π/4 ≤ |ω| ≤ 3π/4. Z 3π/4 2 sin(nω) . . 3π/4 sin x(n) = cos(nω) dω = = 2π π/4 nπ . π/4  jω 3nπ 4  − sin nπ nπ 4    n  3 3n 1 = sinc − sinc 4 4 4 4  5. Solution: Consider Z π Z π 1 j j (π/2−10ω) j nω x(n) = ωe e dω = ω e j (n−10)ωdω 2π −π 2π −π  j (n−10)ω . X e j ω = ω e j (π/2−10ω) . π Z π j (n−10)ω  . j ωe e sin[(n − 10)π ] . − = = cos[(n − 10)π ] − 2π j (n − 10) . −π j (n − 10) π(n − 10)2 −π . n2] = stepseq(10. [xe. title(’DTFT of odd part of x(n)’. [x3. imagX = imag(X). magtick = [-30:10:20].n).1). subplot(2.’LineWidth’.LFS). set(Hf_1.m.wtick).TFS).LFS).9*pi *n)). w = [-500:500]*pi/500.’FontSize’. Xo = dtft(xo.TFS).2.real(Xe).10).LFS). xlabel(’\omega/\pi’.9*pi*n))(u(n)-u(n-10)) clc.’YTick’.7 A complex-valued sequence x(n) can be decomposed into a conjugate symmetric part xe (n) and an conjugate anti-symmetric part xo (n) as xe (n) = Consider F [xe (n)] = = Similarly.’FontSize’.1*pi*n)+j*sin(0.’P0307’). subplot(2. Xe = dtft(xe.0.’XTick’. wtick = sort([-1:0. ylabel(’X_e’.’off’. axis([-1 1 -30 20]).’NumberTitle’.’LineWidth’. xlabel(’\omega/\pi’.4:1 0] ).*x3.’YTick’. plot(w/pi.0.xo.LFS).9 .’FontSize’.^ (-n)).n3] = sigadd(x1.n2). ylabel(’X_o’. set(gca.w). X = dtft(x.’FontSize’.n. axis([-1 1 -30 20]). % Hf_1 = figure. magtick = [-30:10:20]. ylabel(’X_R’.’FontSize’.w).9)−n [cos(0. axis([-1 1 -30 20]).-x2.’FontSize’.Solutions Manual for DSP using Matlab (2nd Edition) 80 2006 P3. title(’DTFT of even part of x(n)’.’Name’.imag(Xo).’FontSize’.2.3). title(’Real part:DTFT of x(n)’. . wtick = sort([-1:0.2.4:1 0]). F [xo (n)] = = ∞ X xe (n)e − j nω −∞  1 x(n) + x ∗ (−n) . set(gca. set(gca.10).1.’LineWidth’.’FontSize’. subplot(2.5).*(cos(0.5).9)^(-n)*(cos(0. diff_o = max(abs(j*imagX-Xo)).LFS).5). diff_e = max(abs(realX-Xe)). [x2.magtick). magtick = [-30:10:20]. 2 = ∞ X 1 −∞ 2 ∗ −∞ xo (n)e − j nω = ∞ X 1 −∞ 2 ∗ − j nω "∞ # ∞ X 1 X − j nω ∗ − j nω = x(n)e + x (−n)e 2 −∞ −∞  − j nω "∞ # ∞ X 1 X − j nω ∗ − j nω = x(n)e − x (−n)e 2 −∞ −∞ x(n) − x (−n) e    1 X e jω − X∗ e jω = j X I e jω 2  1 x(n) − x ∗ (−n) 2  x(n) + x (−n) e    1 X e jω + X∗ e jω = X R e jω 2 ∞ X xo (n) = Matlab Verification using x(n) = 2(0.1*pi*n)+j*sin(0. plot(w/pi. plot(w/pi. n = n3.wtick).TFS).1. xlabel(’\omega/\pi’. wtick = sort([-1:0.1.realX. realX = real(X).magtick). set(gca.4:1 0]).9π n)] [u(n) − u(n − 10)]: % P0307: DTFT after even and odd part decomposition of x(n) % x(n) = 2*(0.n1] = stepseq(0.’FontSize’.n1.’XTick’.2). % [x1. close all. x = 2*(0.m] = evenodd(x.m.LFS).1π n) + j sin(0.w). axis([-1 1 -30 20]).LFS).16. magtick = [-30:10:20]. The magnitude plots of the DTFTs are shown in Figure 3.’XTick’.4).2.2 ω/π 0.6 −0. subplot(2.6 −0.2 ω/π 0.wtick).2 0 0.LFS).6 1 Imaginary part:DTFT of x(n) 20 10 10 0 0 XI XR 20 −10 −10 −20 −20 −30 −1 −0. plot(w/pi.’FontSize’.’LineWidth’. DTFT of even part of x(n) DTFT of odd part of x(n) 20 10 10 0 0 Xe Xo 20 −10 −10 −20 −20 −30 −1 −0.’XTick’.magtick).6 −30 −1 1 Real part:DTFT of x(n) −0.’FontSize’. xlabel(’\omega/\pi’.6 −0.16: Problem P3.2 0 0.2 0 0. set(gca.imagX.2 0 0.6 1 . wtick = sort([-1:0. title(’Imaginary part:DTFT of x(n)’. set(gca.2006 Solutions Manual for DSP using Matlab (2nd Edition) 81 set(gca. print -deps2 .TFS). set(gca.4:1 0])..magtick).2 ω/π 0.wtick).6 1 −30 −1 −0.’YTick’. ylabel(’X_I’.1.7 DTFT plots −0.’YTick’.6 Figure 3.2 ω/π 0.’FontSize’./EPSFILES/P0307.5). ’Name’. close all. diff_i = max(abs(Xi-Xo)). X e e j ω = 12 X e j ω + X ∗ e− j ω .’LineWidth’. w1 = [-500:500]*pi/500. ylabel(’Degrees’.6).Solutions Manual for DSP using Matlab (2nd Edition) 82 2006   P3.abs(Xi). plot(w1/pi. ytick = [0:5:15].TFS).[-500:500]).*x3. plot(w1/pi.1*j*pi*n). F −1  Xo e jω  Z π Z π  j nω 1 1 jω = Xo e e dω = 2π −π 2π −π 1 ∗ = 2 [x(n) − x (−n)] = j x I (n) Matlab Verification using x(n) = e j 0. diff_r = max(abs(Xr-Xe)).’defaultfigurepaperposition’.’YTick’.n. xr = real(x). subplot(4.1*j*pi*n)*(u(n)-u(n-20)). plot(w1/pi.5). % Hf_1 = figure. ylabel(’Degrees’.1). magtick = [-180:90:180].2. title([ ’Phase part of X_e’ ].’FontSize’.LFS).’FontSize’. axis([-1 1 0 15]).abs(Xr).magtick). set(gca.1.ytick). clc. axis([-1 1 -200 200]).TFS). % [x1.0.6]).1. .n1] = stepseq(0.5). plot(w1/pi. ylabel(’|X_e|’.5).5). ytick = [0:5:15].n2] = stepseq(20. as            X e j ω = X e e j ω + X o e j ω .’NumberTitle’.2. set(gca. magtick = [-180:90:180].2.’YTick’. plot(w1/pi.’FontSize’. ylabel(’|X_r|’.n2).2).’FontSize’.0. X 0 e j ω = 21 X e j ω − X ∗ e− j ω Consider Z π Z π    1 1 F −1 X e e j ω = X e e j ω e j nω dω = 2π −π 2π −π ∗ 1 = 2 [x(n) + x (−n)] = x R (n) 1 2    X e j ω + X ∗ e− j ω e j nω dω 1 2    X e j ω − X ∗ e− j ω e j nω dω Similarly.’FontSize’.Xo.’FontSize’. title([ ’Magnitude part of X_e’ ]. subplot(4.LFS).’FontSize’.’LineWidth’.2.1.w1).’LineWidth’.TFS).’P0308’).w1).8 A complex-valued DTFT X e j ω can be decomposed into its conjugate symmetric part X e e j ω and conjugate anti-symmetric part X o e j ω . X = dtft(x.angle(Xr)*180/pi.’FontSize’.2. Xi = dtft(j*xi.LFS). subplot(4.LFS).TFS). magtick = [-180:90:180]. title(’Phase response of x_R’.4). title(’Magnitude response of x_R’. w2 = w2*pi/500.’off’.1.’LineWidth’. x = exp(0.n3] = sigadd(x1. [x3.2.w2] = evenodd(X. set(0. ylabel(’Degrees’. axis([-1 1 -200 200]). n = n3.’LineWidth’.20).0.3).angle(Xi)*180/pi.[0. xi = imag(x). axis([-1 1 0 15]).abs(Xe).5).1. plot(w1/pi.6.’FontSize’.TFS). subplot(4.20).’YTick’.LFS). set(gca.angle(Xe)*180/pi. [Xe. set(Hf_1. ylabel(’|X_i|’.-x2.n1.’FontSize’.n.1πn [u(n) − u (n − 20)]: % P0308: x(n) = exp(0.5). set(gca. axis([-1 1 -200 200]). subplot(4.5).’LineWidth’. [x2.magtick).’FontSize’. subplot(4. title([ ’Magnitude response of j*x_I’ ].’YTick’.w1).n.ytick). Xr = dtft(xr.LFS).1. 5 0 0.5 0 0. set(gca. ylabel(’|X_o|’. plot(w1/pi.magtick).’FontSize’.’FontSize’.’FontSize’.5). ytick = [0:5:15]. The magnitude plots of the DTFTs are shown in Figure 3.TFS).5 180 10 0 −1 0 Phase part of Xe 15 0 −1 −0.LFS).5 1 Phase part of X o o 15 180 Degrees |Xo| 1 90 Magnitude response of j*xI 10 5 0 −1 0. Magnitude response of xR Phase response of xR 180 Degrees |Xr| 15 10 5 0 −1 −0.5 0 0.TFS). title([’Magnitude part of X_o’].LFS). subplot(4.5 1 .17: Problem P3.2.1.angle(Xo)*180/pi.5 1 180 Degrees |Xi| −0.1. ylabel(’Degrees’. axis([-1 1 -200 200]).’FontSize’.’YTick’. plot(w1/pi.5 Phase response of j*xI 15 10 5 −0.5 0 ω/π 0.5 0 0. set(gca.TFS).ytick).’LineWidth’.. subplot(4.LFS).abs(Xo).5).8 DTFT plots 0 ω/π 0. axis([-1 1 0 15])./EPSFILES/P0308.5 90 0 −90 −180 −1 1 Magnitude part of X −0.’YTick’.5 90 0 −90 −180 −1 1 Magnitude part of Xe Degrees |Xe| 5 −0. xlabel(’\omega/\pi’.5 1 90 0 −90 −180 −1 −0.’YTick’.LFS). magtick = [-180:90:180].’LineWidth’. print -deps2 .7).2.8).’FontSize’.magtick). xlabel(’\omega/\pi’.2006 Solutions Manual for DSP using Matlab (2nd Edition) 83 title([ ’Phase response of j*x_I’ ]. set(gca. title([’Phase part of X_o’].5 Figure 3.5 0 −90 −180 −1 1 0 0.’FontSize’.17.’FontSize’.5 −0. M−1 X 0 cos[(ω + ω0 )n] = M−1 X 0 cos[{ω − (2π − ω0 )}n] cos[{ω − (2π − ω0 )}(M − 1)] sin[{ω − (2π − ω0 )}M/2] = sin[{ω − (2π − ω0 )}/2] Substituting (3.0.5*(exp(-j*(w-w0)*((M-1)/2)). we have XR e jω  = M−1 X 0 M−1 M−1 1X 1X cos(ω0 n) cos(nω) = cos[(ω − ω0 )n] + cos[(ω + ω0 )n] 2 0 2 0 (3.TFS).5* (exp(-j*(w+w0)*((M-1)/2)).1./sin((w+w0+eps)/2)).’NumberTitle’. plot(w/pi.3) Similarly.9]).LFS). magX = abs(X). 0.’FontSize’. set(Hf_1. w0 = pi/2.1).4) . ylabel(’|X|’..*sin((w-w0)*M/2).’FontSize’.’Name’./sin((w-w0+eps)/2)) + . %% M = 5 M = 5.. % Hf_1 = figure. 25. M−1 X 0   M−1 1 1 − e j (ω−ω0 )M 1 X  j (ω−ω0 )n 1 − e− j (ω−ω0 )M e + e− j (ω−ω0 )n = + 2 0 2 1 − e j (ω−ω0 ) 1 − e− j (ω−ω0 )   1 1 − cos(ω − ω0 ) − cos[(ω − ω0 )M] + cos[(ω − ω0 )(M − 1)] = 2 1 − cos(ω − ω0 ) ! 2 1 2 sin [(ω − ω0 )/2] + 2 sin[(ω − ω0 )/2] sin[(ω − ω0 )(M − 21 )] = 2 2 sin2 [(ω − ω0 )/2] ! 1 sin[(ω − ω0 )/2] + sin[(ω − ω0 )(M − 21 )] = 2 sin[(ω − ω0 )/2] cos[(ω − ω0 )n] = = cos[(ω − ω0 )(M − 1)] sin[(ω − ω0 )M/2] sin[(ω − ω0 )/2] (3.  Matlab Computation and plot of X R e j ω for ω0 = π/2 and M = 5. 100: % P0309: DTFT of sinusoidal pulse for different values of M clc.2) Consider the first sum in (3.6. X = 0. then the real part of its DTFT X e j ω is given by ∞  X XR e jω = x(n) cos(nω) −∞ Hence for the given sinusoidal pulse.’off’.9 The real-part of the DTFT of a sinusoidal pulse x(n) = (cos ω0 n) R M (n):  First note that if the sequence x(n) is a real-valued sequence. subplot(4. set(0. 15.2). phaX = angle(X).3) and (3. axis([-1 1 0 4]).5).’LineWidth’.’P0309’).’FontSize’. we obtain the desired result. xlabel(’\omega/\pi’.*sin((w+w0)*M/2).’defaultfigurepaperposition’. w = [-500:500]*pi/500.[0.2). title([’Magnitude Response M = 5’].Solutions Manual for DSP using Matlab (2nd Edition) 84 2006 P3. close all.2.magX.LFS).4) in (3. (3. 5* (exp(-j*(w+w0)*((M-1)/2)). magX = abs(X). plot(w/pi. ylabel(’|X|’.ytick).5* (exp(-j*(w+w0)*((M-1)/2))./sin((w-w0+eps)/2)) + .’LineWidth’.TFS).set(gca. %% M = 25 M = 25. xlabel(’\omega/\pi’.’FontSize’.magX.’LineWidth’. axis([-1 1 -200 200]).’FontSize’.. plot(w/pi.2.’FontSize’.magX.*sin((w+w0)*M/2).’YTick’.5).’FontSize’.’YTick’.  The plots of X R e j ω are shown in Figure 3. ylabel(’Degrees’.’FontSize’.’YTick’.’YTickmode’. w0 = pi/2. magX = abs(X).’FontSize’.ytick). w = [-500:500]*pi/500.LFS). title([char(10) ’Magnitude Response M = 25’ char(10)]. w = [-500:500]*pi/500. subplot(4.2. X = 0. X = 0.ytick).1.’YTickmode’.ytick).’FontSize’.LFS).TFS). w = [-500:500]*pi/500.’FontSize’. axis([-1 1 0 15]).phaX*180/pi.LFS). phaX = angle(X). ylabel(’Degrees’.’manual’./EPSFILES/P0309./sin((w-w0+eps)/2)) + .’YTickmode’.5).18.5). plot(w/pi.’FontSize’. 0.7). title([’Phase Response M = 5’].’manual’. subplot(4.*sin((w-w0)*M/2). 0. % subplot(4.magX. ylabel(’|X|’. ytick = [-180 0 180].’LineWidth’..LFS).’FontSize’. plot(w/pi. xlabel(’\omega/\pi’. %% M = 15 M = 15. ytick = [-180 0 180].5). plot(w/pi. title([char(10) ’Phase Response M = 25’ char(10)].TFS). 85 .5).’manual’.*sin((w+w0)*M/2). xlabel(’\omega/\pi’.5*(exp(-j*(w-w0)*((M-1)/2)).2). plot(w/pi.’LineWidth’.5* (exp(-j*(w+w0)*((M-1)/2)). axis([-1 1 -200 200]).2.’manual’. subplot(4.’FontSize’.1.1. xlabel(’\omega/\pi’. ylabel(’Degrees’. set(gca.6)..’FontSize’.TFS).2006 Solutions Manual for DSP using Matlab (2nd Edition) subplot(4.2.1. ylabel(’|X|’.5*(exp(-j*(w-w0)*((M-1)/2)).4).LFS).set(gca./sin((w-w0+eps)/2)) + .’YTickmode’.*sin((w-w0)*M/2). ytick = [0 50 75].TFS). xlabel(’\omega/\pi’. w0 = pi/2. ylabel(’Degrees’.LFS).’FontSize’..’FontSize’.set(gca. xlabel(’\omega/\pi’. % subplot(4.LFS).’YTickmode’.1.*sin((w-w0)*M/2).LFS).’LineWidth’.3). print -deps2 .’LineWidth’.’FontSize’.2.TFS).LFS).1.5*(exp(-j*(w-w0)*((M-1)/2)).phaX*180/pi. axis([-1 1 -200 200]). axis([-1 1 0 10]).phaX*180/pi.’FontSize’.’FontSize’. ytick = [-180 0 180].’YTick’.’FontSize’.LFS). axis([-1 1 -200 200]).5).*sin((w+w0)*M/2).’manual’. phaX = angle(X). X = 0.LFS).’LineWidth’. ytick = [-180 0 180].ytick).TFS). title([char(10) ’Phase Response M = 101’ char(10)]. set(gca. phaX = angle(X). %%M = 101 M = 101./sin((w+w0+eps)/2)).1.LFS).. axis([-1 1 0 75]).’YTick’. subplot(4.LFS).5).8)./sin((w+w0+eps)/2)). title([char(10) ’Magnitude Response M = 15’ char(10)]. title([char(10) ’Phase Response M = 15’ char(10)].2.’FontSize’. 0.phaX*180/pi.. magX = abs(X).. xlabel(’\omega/\pi’. plot(w/pi.LFS). w0 = pi/2.2./sin((w+w0+eps)/2)). title([char(10) ’Magnitude Response M = 101’ char(10)].5).’FontSize’.’FontSize’. 5 1 0 −180 −1 −0.18: Problem P3.5 0 −180 −1 1 Magnitude Response M = 101 −0.5 0 ω/π 0.5 1 Phase Response M = 25 15 Degrees 180 |X| 10 5 −0.5 1 .5 Figure 3.5 0 ω/π 0.5 0 −180 −1 1 Magnitude Response M = 25 −0.5 0 ω/π 0.5 0 ω/π 0.5 0 −180 −1 1 Magnitude Response M = 15 Degrees |X| 0.9 plots 0 ω/π 0.5 0 ω/π 0.5 1 Phase Response M = 101 75 Degrees 180 |X| 50 0 −1 0 ω/π 180 5 0 −1 −0.5 0 ω/π 0.Solutions Manual for DSP using Matlab (2nd Edition) 86 Magnitude Response M = 5 Phase Response M = 5 4 180 Degrees |X| 3 2 1 0 −1 −0.5 Phase Response M = 15 10 0 −1 2006 −0.5 1 −0. ’FontSize’.LFS).1. axis([-1 1 -200 200]). plot(w/pi.’off’. ylabel(’Degrees’.’LineWidth’.’LineWidth’. title([’Scaled Magnitude from the Property’]. wtick = sort([-1:0.2. subplot(2.2:1.’FontSize’. set(0.4:1]). phaX = angle(X)*180/pi.2].magX.LFS).2.phaX.5).1). axis([-1 1 -200 200]). magtick = [0:0.’P0310a’). magX = abs(X). subplot(2.2]).’XTick’.magtick).’YTick’. ylabel(’|X|’. plot(w/pi. ylabel(’|X|’. n = 0:M.2). % x(n) & its DTFT [x. magTw = magTw/max(magTw).n. axis([-1 1 0 1.0. Tw = dtft(Tn. set(gca. magtick = [-180:60:180].’XTick’. subplot(2.LFS).pi. print -deps2 .’LineWidth’.’FontSize’.LFS).’XTick’.2.phaY.’FontSize’.3).’defaultfigurepaperposition’.5). w = linspace(-pi.5:1]). DTFT calculations and plots using properties of the DTFT: 1. wtick = sort([-1:0.magtick). set(gca.w).4]). xlabel(’\omega/\pi’.2:1. magY = abs(Y)/max(abs(Y)).1.magY.magtick).1.’YTick’.wtick). set(gca.. Tn = (1-(abs(M-1-2*n)/(M+1))). x(n) = T10 (−n):  X e j ω = F[x(n)] = F[T10 (−n)] = F[T10 (n)]|ω→−ω = F[T10 (n)]∗ (∵ real signal Matlab script: % P0310a: DTFT of x(n) = T_10(-n) clc. close all. xlabel(’\omega/\pi’. X = dtft(x.2006 Solutions Manual for DSP using Matlab (2nd Edition) 87 P3.n.’LineWidth’.’FontSize’. magtick = [0:0.TFS). % DTFT of x(n) from the Property Y = fliplr(Tw). title([’Phase of X’].19.’FontSize’.wtick). magtick = [-180:60:180].2. set(gca.7.  The property verification using plots of X e j ω is shown in Figure 3. set(gca.n).LFS).10 x(n) = T10 (n) is a triangular pulse given in Problem P4. title([’Phase from the Property’]. axis([-1 1 0 1. magTw = abs(Tw).magtick).’XTick’.wtick). wtick = sort([-1:0. phaY = angle(Y)*180/pi.’FontSize’.’FontSize’.’YTick’.w).TFS).TFS). phaTw = angle(Tw)*180/pi. ylabel(’Degrees’. xlabel(’\omega/\pi’.4). % % Triangular Window T_10(n) & its DTFT M = 10./EPSFILES/P0310a.LFS).n] = sigfold(Tn.5:1]).’FontSize’.5).TFS).LFS). subplot(2.1. magX = magX/max(magX).[0. title([’Scaled Magnitude of X’]. plot(w/pi.2].’FontSize’.LFS).wtick. % Hf_1 = figure. set(gca. . plot(w/pi. xlabel(’\omega/\pi’.5:1]).’FontSize’.501).3. wtick = sort([-1:0.’FontSize’.5). set(gca. set(Hf_1.’Name’.2]).’NumberTitle’.’YTick’. 10a plots −0.2 0 −1 −0.2 0 −1 −180 −0.4 60 0 −60 −120 0.2 |X| 2006 −180 −0.19: Problem P3.5 0 ω/π 0.2 180 1 120 Degrees |X| 0.6 0.4 60 0 −60 −120 0.5 ω/π 1 180 1 120 Degrees 0.5 0 ω/π 0.Solutions Manual for DSP using Matlab (2nd Edition) 88 Scaled Magnitude of X Phase of X 1.5 1 −1 −0.8 0.6 0.8 0.6 Figure 3.2 ω/π 0.6 1 .2 0.5 Phase from the Property 1.5 1 −1 Scaled Magnitude from the Property 0 0. M = 10 clc.n.20.[0.2006 Solutions Manual for DSP using Matlab (2nd Edition) 2. magtick = [0:0.wtick).w). axis([-1 1 0 1. axis([-1 1 -200 200]).5).2:1. magTw = magTw/max(magTw). plot(w/pi.phaY.4).’XTick’. wtick = sort([-1:0.’FontSize’.5:1]).7.-x1. phaY = angle(Y)*180/pi. magX = abs(X).’LineWidth’.magX. phaTw = angle(Tw)*180/pi.’YTick’. plot(w/pi. % T_10(n) = [1-(abs(M-1-2*n)/(M+1)) ]*R_M(n).’FontSize’.TFS).5:1]).w).501).n1] = sigshift(Tn. X = dtft(x. set(gca. % Hf_1 = figure.wtick).’YTick’. plot(w/pi. set(gca. xlabel(’\omega/\pi’.’FontSize’.2:1.’Name’.n. title([’Phase from the Property’].n] = sigadd(Tn. close all.10).LFS).’FontSize’. magtick = [0:0.’YTick’. wtick = sort([-1:0.1.’XTick’. set(gca.magtick). magtick = [-180:60:180].4]).phaX.1.2]).’FontSize’. subplot(2. n = 0:M. title([’Phase of X’].LFS).magtick).’off’.magtick).’FontSize’. [x. phaX = angle(X)*180/pi. set(Hf_1.2. subplot(2.5:1]).’FontSize’. axis([-1 1 -200 200]).’XTick’. title([’Scaled Magnitude from the Property’].’XTick’. set(gca.’defaultfigurepaperposition’.’FontSize’.2.’FontSize’. Tn = (1-(abs(M-1-2*n)/(M+1))).1).’YTick’./EPSFILES/P0310b.LFS).’NumberTitle’.*Tw.n1). x(n) = T10 (n) − T10 (n − 10):  X e j ω = F[x(n)] = F[T10 (n) − T10 (n − 10)] = F[T10 (n)] − F[T10 (n)]e− j 10ω  = 1 − e− j 10ω F[T10 (n)] Matlab script: % P0310b: DTFT of T_10(n)-T_10(n-10). ylabel(’|X|’.1. ylabel(’Degrees’.0.TFS).5).’P0310b’). set(gca.4:1]).TFS).wtick).’FontSize’. % x(n) & its DTFT [x1. wtick = sort([-1:0.’FontSize’. axis([-1 1 0 1. print -deps2 . set(gca.wtick.’FontSize’.LFS). magY = abs(Y)/max(abs(Y)).LFS). % DTFT of x(n) from the Property Y = Tw-exp(-j*w*10).2.  The property verification using plots of X e j ω is shown in Figure 3.LFS).n. plot(w/pi.LFS). magtick = [-180:60:180].pi. subplot(2.2).’LineWidth’. % % Triangular Window T_10(n) & its DTFT M = 10.2]).3). subplot(2. ylabel(’|X|’.5).magtick). magTw = abs(Tw).2].magY.5). xlabel(’\omega/\pi’.TFS).n.LFS). xlabel(’\omega/\pi’.2].. Tw = dtft(Tn. wtick = sort([-1:0.’LineWidth’. title([’Scaled Magnitude of X’].2. set(gca. ylabel(’Degrees’. set(0.’LineWidth’. magX = magX/max(magX). 89 . w = linspace(-pi.1. xlabel(’\omega/\pi’. 8 0.2 0 −1 −0.6 Figure 3.2 0 −1 −180 −0.2 ω/π 0.5 1 −1 Scaled Magnitude from the Property 0 0.5 Phase from the Property 1.2 |X| 2006 −180 −0.6 1 .5 ω/π 1 180 1 120 Degrees 0.5 1 −1 −0.2 0.4 60 0 −60 −120 0.20: Problem P3.Solutions Manual for DSP using Matlab (2nd Edition) 90 Scaled Magnitude of X Phase of X 1.5 0 ω/π 0.6 0.10b plots −0.6 0.8 0.4 60 0 −60 −120 0.2 180 1 120 Degrees |X| 0.5 0 ω/π 0. 2006 Solutions Manual for DSP using Matlab (2nd Edition) 3. x(n) = T10 (n) ∗ T10 (−n):  X e j ω = F[x(n)] = F[T10 (n) ∗ T10 (−n)] = F[T10 (n)] ∗ F[T10 (n)]∗ = |F[T10 (n)]|2 Matlab script: % P0310c: DTFT of T_10(n) Conv T_10(-n) % T_10(n) = [1-(abs(M-1-2*n)/(M+1)) ]*R_M(n), M = 10 clc; close all; set(0,’defaultfigurepaperposition’,[0,0,7,4]); % % Triangular Window T_10(n) & its DTFT M = 10; n = 0:M; Tn = (1-(abs(M-1-2*n)/(M+1))); w = linspace(-pi,pi,501); Tw = dtft(Tn,n,w); magTw = abs(Tw); magTw = magTw/max(magTw); phaTw = angle(Tw)*180/pi; % x(n) & its DTFT [x1,n1] = sigfold(Tn,n); [x,n] = conv_m(Tn,n,x1,n1); X = dtft(x,n,w); magX = abs(X); magX = magX/max(magX); phaX = angle(X)*180/pi; % DTFT of x(n) from the Property Y = Tw.*fliplr(Tw); magY = abs(Y)/max(abs(Y)); phaY = angle(Y)*180/pi; % Hf_1 = figure; set(Hf_1,’NumberTitle’,’off’,’Name’,’P0310c’); subplot(2,2,1); plot(w/pi,magX,’LineWidth’,1.5); axis([-1 1 0 1.2]); wtick = sort([-1:0.5:1]); magtick = [0:0.2:1.2]; xlabel(’\omega/\pi’,’FontSize’,LFS); ylabel(’|X|’,’FontSize’,LFS); title([’Scaled Magnitude of X’],’FontSize’,TFS); set(gca,’XTick’,wtick); set(gca,’YTick’,magtick); subplot(2,2,2); plot(w/pi,phaX,’LineWidth’,1.5); axis([-1 1 -200 200]); wtick = sort([-1:0.5:1]); magtick = [-180:60:180]; xlabel(’\omega/\pi’,’FontSize’,LFS); ylabel(’Degrees’,’FontSize’,LFS); title([’Phase of X’],’FontSize’,TFS); set(gca,’XTick’,wtick); set(gca,’YTick’,magtick); subplot(2,2,3); plot(w/pi,magY,’LineWidth’,1.5); axis([-1 1 0 1.2]); wtick = sort([-1:0.5:1]); magtick = [0:0.2:1.2]; xlabel(’\omega/\pi’,’FontSize’,LFS); ylabel(’|X|’,’FontSize’,LFS); title([’Scaled Magnitude from the Property’],’FontSize’,TFS); set(gca,’XTick’,wtick); set(gca,’YTick’,magtick); subplot(2,2,4); plot(w/pi,phaY,’LineWidth’,1.5); axis([-1 1 -200 200]); wtick = sort([-1:0.4:1]); magtick = [-180:60:180]; xlabel(’\omega/\pi’,’FontSize’,LFS); ylabel(’Degrees’,’FontSize’,LFS); title([’Phase from the Property’],’FontSize’,TFS); set(gca,’XTick’,wtick,’YTick’,magtick); print -deps2 ../EPSFILES/P0310c;  The property verification using plots of X e j ω is shown in Figure 3.21. 91 Solutions Manual for DSP using Matlab (2nd Edition) 92 Scaled Magnitude of X Phase of X 1.2 180 1 120 Degrees |X| 0.8 0.6 0.4 60 0 −60 −120 0.2 0 −1 −180 −0.5 0 ω/π 0.5 1 −1 Scaled Magnitude from the Property 0 0.5 ω/π 1 180 1 120 Degrees 0.8 0.6 0.4 60 0 −60 −120 0.2 0 −1 −0.5 Phase from the Property 1.2 |X| 2006 −180 −0.5 0 ω/π 0.5 1 −1 −0.6 Figure 3.21: Problem P3.10c plots −0.2 ω/π 0.2 0.6 1 2006 Solutions Manual for DSP using Matlab (2nd Edition) 93 4. x(n) = T10 (n)e j πn :  X e j ω = F[x(n)] = F[T10 (n)e j πn ] = F[T10 (n)]|ω→(ω−π) Matlab script: % P0310d: DTFT of T_10(n)*exp(j*pi*n) % T_10(n) = [1-(abs(M-1-2*n)/(M+1)) ]*R_M(n), M = 10 clc; close all; set(0,’defaultfigurepaperposition’,[0,0,7,4]); % % Triangular Window T_10(n) & its DTFT M = 10; n = 0:M; Tn = (1-(abs(M-1-2*n)/(M+1))); w = linspace(-pi,pi,501); Tw = dtft(Tn,n,w); magTw = abs(Tw); magTw = magTw/max(magTw); phaTw = angle(Tw)*180/pi; % x(n) & its DTFT x = Tn.*exp(j*pi*n); X = dtft(x,n,w); magX = abs(X); magX = magX/max(magX); phaX = angle(X)*180/pi; % DTFT of x(n) from the Property Y = [Tw(251:501),Tw(1:250)]; magY = abs(Y)/max(abs(Y)); phaY = angle(Y)*180/pi; % Hf_1 = figure; set(Hf_1,’NumberTitle’,’off’,’Name’,’P0310d’); subplot(2,2,1); plot(w/pi,magX,’LineWidth’,1.5); axis([-1 1 0 1.2]); wtick = sort([-1:0.5:1]); magtick = [0:0.2:1.2]; xlabel(’\omega/\pi’,’FontSize’,LFS); ylabel(’|X|’,’FontSize’,LFS); title([’Scaled Magnitude of X’],’FontSize’,TFS); set(gca,’XTick’,wtick); set(gca,’YTick’,magtick); subplot(2,2,2); plot(w/pi,phaX,’LineWidth’,1.5); axis([-1 1 -200 200]); wtick = sort([-1:0.5:1]); magtick = [-180:60:180]; xlabel(’\omega/\pi’,’FontSize’,LFS); ylabel(’Degrees’,’FontSize’,LFS); title([’Phase of X’],’FontSize’,TFS); set(gca,’XTick’,wtick); set(gca,’YTick’,magtick); subplot(2,2,3); plot(w/pi,magY,’LineWidth’,1.5); axis([-1 1 0 1.2]); wtick = sort([-1:0.5:1]); magtick = [0:0.2:1.2]; xlabel(’\omega/\pi’,’FontSize’,LFS); ylabel(’|X|’,’FontSize’,LFS); title([’Scaled Magnitude from the Property’],’FontSize’,TFS); set(gca,’XTick’,wtick); set(gca,’YTick’,magtick); subplot(2,2,4); plot(w/pi,phaY,’LineWidth’,1.5); axis([-1 1 -200 200]); wtick = sort([-1:0.4:1]); magtick = [-180:60:180]; xlabel(’\omega/\pi’,’FontSize’,LFS); ylabel(’Degrees’,’FontSize’,LFS); title([’Phase from the Property’],’FontSize’,TFS); set(gca,’XTick’,wtick,’YTick’,magtick); print -deps2 ../EPSFILES/P0310d;  The property verification using plots of X e j ω is shown in Figure 3.22. Solutions Manual for DSP using Matlab (2nd Edition) 94 Scaled Magnitude of X Phase of X 1.2 180 1 120 Degrees |X| 0.8 0.6 0.4 60 0 −60 −120 0.2 0 −1 −180 −0.5 0 ω/π 0.5 1 −1 Scaled Magnitude from the Property 0 0.5 ω/π 1 180 1 120 Degrees 0.8 0.6 0.4 60 0 −60 −120 0.2 0 −1 −0.5 Phase from the Property 1.2 |X| 2006 −180 −0.5 0 ω/π 0.5 1 −1 −0.6 Figure 3.22: Problem P3.10d plots −0.2 ω/π 0.2 0.6 1 2006 Solutions Manual for DSP using Matlab (2nd Edition) 5. x(n) = cos(0.1π n)T10 (n):    1  j 0.1πn X e j ω = F[x(n)] = F[cos(0.1π n)T10 (n)] = F + e− j 0.1πn T10 (n) e 2 1 1 = F[T10 (n)]|ω→(ω−0.1π) + F[T10 (n)]|ω→(ω+0.1π) 2 2 Matlab script: % P0310e: DTFT of x(n) = T_10(-n) clc; close all; set(0,’defaultfigurepaperposition’,[0,0,7,4]); % % Triangular Window T_10(n) & its DTFT M = 10; n = 0:M; Tn = (1-(abs(M-1-2*n)/(M+1))); w = linspace(-pi,pi,501); Tw = dtft(Tn,n,w); magTw = abs(Tw); magTw = magTw/max(magTw); phaTw = angle(Tw)*180/pi; % x(n) & its DTFT x = cos(0.1*pi*n).*Tn; X = dtft(x,n,w); magX = abs(X); magX = magX/max(magX); phaX = angle(X)*180/pi; % DTFT of x(n) from the Property Y = 0.5*([Tw(477:501),Tw(1:476)]+[Tw(26:501),Tw(1:25)]); magY = abs(Y)/max(abs(Y)); phaY = angle(Y)*180/pi; % Hf_1 = figure; set(Hf_1,’NumberTitle’,’off’,’Name’,’P0310e’); subplot(2,2,1); plot(w/pi,magX,’LineWidth’,1.5); axis([-1 1 0 1.2]); wtick = sort([-1:0.5:1]); magtick = [0:0.2:1.2]; xlabel(’\omega/\pi’,’FontSize’,LFS); ylabel(’|X|’,’FontSize’,LFS); title([’Scaled Magnitude of X’],’FontSize’,TFS); set(gca,’XTick’,wtick); set(gca,’YTick’,magtick); subplot(2,2,2); plot(w/pi,phaX,’LineWidth’,1.5); axis([-1 1 -200 200]); wtick = sort([-1:0.5:1]); magtick = [-180:60:180]; xlabel(’\omega/\pi’,’FontSize’,LFS); ylabel(’Degrees’,’FontSize’,LFS); title([’Phase of X’],’FontSize’,TFS); set(gca,’XTick’,wtick); set(gca,’YTick’,magtick); subplot(2,2,3); plot(w/pi,magY,’LineWidth’,1.5); axis([-1 1 0 1.2]); wtick = sort([-1:0.5:1]); magtick = [0:0.2:1.2]; xlabel(’\omega/\pi’,’FontSize’,LFS); ylabel(’|X|’,’FontSize’,LFS); title([’Scaled Magnitude from the Property’],’FontSize’,TFS); set(gca,’XTick’,wtick); set(gca,’YTick’,magtick); subplot(2,2,4); plot(w/pi,phaY,’LineWidth’,1.5); axis([-1 1 -200 200]); wtick = sort([-1:0.4:1]); magtick = [-180:60:180]; xlabel(’\omega/\pi’,’FontSize’,LFS); ylabel(’Degrees’,’FontSize’,LFS); title([’Phase from the Property’],’FontSize’,TFS); set(gca,’XTick’,wtick,’YTick’,magtick); print -deps2 ../EPSFILES/P0310e;  The property verification using plots of X e j ω is shown in Figure 3.23. 95 Solutions Manual for DSP using Matlab (2nd Edition) 96 Scaled Magnitude of X Phase of X 1.2 180 1 120 Degrees |X| 0.8 0.6 0.4 60 0 −60 −120 0.2 0 −1 −180 −0.5 0 ω/π 0.5 1 −1 Scaled Magnitude from the Property 0 0.5 ω/π 1 180 1 120 Degrees 0.8 0.6 0.4 60 0 −60 −120 0.2 0 −1 −0.5 Phase from the Property 1.2 |X| 2006 −180 −0.5 0 ω/π 0.5 1 −1 −0.6 Figure 3.23: Problem P3.10e plots −0.2 ω/π 0.2 0.6 1 2006 Solutions Manual for DSP using Matlab (2nd Edition) 97  P3.11 Determination and plots of the frequency response function H e j ω . 1. h(n) = (0.9)|n| ∞ −1 ∞ ∞ ∞ X X X X X  H e jω = (n)e− j nω = .9−n e− j nω + .9n e− j nω = .9n e j nω − 1 + .9n e− j nω h=−∞ 0=−∞ 0=0 0=0 0=0 1 1 + −1 j ω 1 − 0.9e 1 − 0.9e− j ω 0.19 = 1.81 − 1.8 cos(ω) = Matlab script: % P0311a: h(n) = (0.9)^|n|; H(w) = 0.19/(1.81-1.8*cos(w)); clc; close all; set(0,’defaultfigurepaperposition’,[0,0,6,3]); w = [-300:300]*pi/300; H = 0.19*ones(size(w))./(1.81-1.8*cos(w)); magH = abs(H); phaH = angle(H)*180/pi; Hf_1 = figure; set(Hf_1,’NumberTitle’,’off’,’Name’,’P0311a’); subplot(2,1,1); plot(w/pi,magH,’LineWidth’,1.5); axis([-1 1 0 20]); wtick = [-1:0.2:1]; magtick = [0:5:20]; xlabel(’\omega / \pi’,’FontSize’,LFS); ylabel(’|H|’,’FontSize’,LFS); title(’Magnitude response of h(n) = (0.9)^{|n|}’,’FontSize’,TFS); set(gca,’XTick’,wtick); set(gca,’YTick’,magtick); subplot(2,1,2); plot(w/pi,phaH,’LineWidth’,1.5); axis([-1 1 -180 180]); wtick = [-1:0.2:1]; magtick = [-180:60:180]; xlabel(’\omega / \pi’,’FontSize’,LFS); ylabel(’Degrees’,’FontSize’,LFS); title(’Phase response of h(n) = (0.9)^{|n|}’,’FontSize’,TFS); set(gca,’XTick’,wtick,’YTick’,magtick); print -deps2 ../EPSFILES/P0311a;  The magnitude and phase response plots of H e j ω are shown in Figure 3.24. Magnitude response of h(n) = (0.9)|n| 20 |H| 15 10 5 0 −1 −0.8 −0.6 −0.4 −0.2 0 ω/π 0.2 0.4 0.6 0.8 1 0.6 0.8 1 |n| Degrees Phase response of h(n) = (0.9) 180 120 60 0 −60 −120 −180 −1 −0.8 −0.6 −0.4 −0.2 0 ω/π 0.2 Figure 3.24: Problem P3.11a plots 0.4 11b plots 0.4 −0. ’[u(n+20)-u(n-20)]’].-h2.1.1. plot(w/pi. ylabel(’|H|’.2 n)×[u(n+20)−u(n−20)] 180 120 60 0 −60 −120 −180 −1 −0.’FontSize’.6 −0.LFS).’YTick’.LFS).TFS).LFS).2 × n)×[u(n+20)−u(n−20)] 6 5 4 3 2 1 0 −1 −0. h = sinc(0.2:1].TFS).5).1. ’\times[u(n+20)-u(n-20)]’]. h(n) = sinc (0.’defaultfigurepaperposition’. plot(w/pi.0. ylabel(’Degrees’.8 1 .w).2 0 ω/π 0.25: Problem P3.n2] = stepseq(20.2 0 ω/π 0. magtick = [-180:60:180]. xlabel(’\omega / \pi’.magtick). n = n3.’P0311b’).’XTick’.magtick).. set(gca.  The magnitude and phase response plots of H e j ω are shown in Figure 3.1). subplot(2.n.5).8 −0.’FontSize’. phaH = angle(H)*180/pi.2 0.1.magH.’FontSize’.*h3.4 0. [h1.’XTick’..Solutions Manual for DSP using Matlab (2nd Edition) 98 2006 2.n3] = sigadd(h1.2). H = dtft(h.’FontSize’. magH = abs(H).8 −0. Matlab script: % P0311b: h(n) = sinc(0. Hf_1 = figure.[0.n2). set(gca. title([’Phase response of h(n) = sinc(0.6 0. |H| Magnitude response of h(n) = sinc(0.wtick..n1] = stepseq(-20. [h3. wtick = [-1:0.’Name’..phaH. title([’Magnitude response of h(n) = sinc(0. w = [-300:300]*pi/300.20).20).’FontSize’. xlabel(’\omega / \pi’.’off’.n1.2 n)’ .2 0.25. set(Hf_1.2*n)*[u(n+20)-u(n-20)] clc.’LineWidth’.’LineWidth’. print -deps2 .set(0.2 \times n)\times’ ..-20. axis([-1 1 0 6]).6 0. set(gca.6. close all.2*n). [h2.’NumberTitle’.’FontSize’./EPSFILES/P0311b.3]).6 −0.LFS).2n) [u (n + 20) − u (n − 20)] .2:1].-20.4 −0. magtick = [0:1:6]. subplot(2.’YTick’.8 1 Degrees Phase response of h(n) = sinc(0. wtick = [-1:0.wtick).4 Figure 3. axis([-1 1 -200 200]). where sinc 0 = 1. 2).8 1 0.LFS).2n) [u(n) − u (n − 40)] Matlab script: % P0311c: h(n) = sinc(0.2:1]. H = dtft(h.’FontSize’.’Name’. [h3.1). set(gca.0.LFS). title([’Magnitude response of h(n) = sinc(0.magtick).8 −0. plot(w/pi.3]). xlabel(’\omega / \pi’.w).-h2.’XTick’.LFS).26: Problem P3.. xlabel(’\omega / \pi’.  The magnitude and phase response plots of H e j ω are shown in Figure 3.4 0. set(0. ’[u(n)-u(n-40)]’]. [h1.6 −0.2)×[u(n)−u(n−40)] 180 120 60 0 −60 −120 −180 −1 −0.1.2n)×[u(n)−u(n−40)] 5 4 3 2 1 0 −1 −0. plot(w/pi.2006 Solutions Manual for DSP using Matlab (2nd Edition) 99 3. print -deps2 .8 −0. set(gca.’FontSize’.n3] = sigadd(h1. title([’Phase response of h(n) = sinc(0.n. magH = abs(H).’NumberTitle’.wtick. h = sinc(0.4 −0. set(Hf_1.’FontSize’. |H| Magnitude response of h(n) = sinc(0.6 0. close all.2)\times’ ..’P0311c’).2*n)*[u(n)-u(n-40)] clc..’FontSize’.26.’YTick’. axis([-1 1 0 5]).2 Figure 3.’FontSize’.1. subplot(2.. wtick = [-1:0. axis([-1 1 -180 180]).’FontSize’.2 0.phaH.. set(gca.magtick). phaH = angle(H)*180/pi. magtick = [0:1:5]./EPSFILES/P0311c.5).TFS).wtick).5).0.’LineWidth’.magH.6 .*h3.TFS).n1] = stepseq(0.2 0 ω/π 0. Hf_1 = figure. ’[u(n)-u(n-40)]’]. subplot(2.’defaultfigurepaperposition’.’XTick’.11c plots 0.40).n2] = stepseq(40. [h2.0.1.4 0.’LineWidth’.2n)\times’ . magtick = [-180:60:180].’off’. ylabel(’|H|’.40).[0.6.8 1 Degrees Phase response of h(n) = sinc(0. ylabel(’Degrees’.2:1].6 −0.’YTick’. w = [-300:300]*pi/300.2 0 ω/π 0.2*n).LFS). wtick = [-1:0. n = n3. h(n) = sinc (0.n2).1.n1.4 −0. wtick = [-1:0. set(gca.’YTick’.5) +(0. H = (2-0. axis([-1 1 1 4]). subplot(2. title(’Phase response:h(n) = [(0.11d plots 0.5 2 1./(1-0.9*exp(-j*w)).wtick).2*exp(-j*2*w)) clc..3]).Solutions Manual for DSP using Matlab (2nd Edition) 100   4. set(Hf_1. % H(w) = (2-0.1).4) ] u(n) 180 120 60 0 −60 −120 −180 −1 −0.5:4].TFS).5 3 2.8 1 Degrees Phase response:h(n) = [(0.6 0. axis([-1 1 -180 180]). wtick = [-1:0.4 −0. magH = abs(H).5)n + (0.5)^n+(0.LFS).2). plot(w/pi.4 −0.4e− j ω Matlab script: % P0311d: h(n) = ((0.’FontSize’.2e− j 2ω ∞ X 0=0 .’LineWidth’.5 1 −1 −0.5)^n+(0.’P0311d’).’off’.’XTick’.magtick).4)n] u(n) 4 3.TFS).9*exp(-j*w)+0. xlabel(’\omega / \pi’.’Name’.1.’FontSize’.5).2 0.’LineWidth’. Hf_1 = figure.LFS).4)^n] u(n)’.0.8 −0. print -deps2 .27: Problem P3.4)^n] u(n)’.2:1]. set(gca.8 −0. set(0.magH.6 −0.LFS).wtick. w = [-300:300]*pi/300. ylabel(’|H|’. subplot(2.’NumberTitle’.2:1]. title(’Magnitude response:h(n) = [(0. |H| Magnitude response:h(n) = [(0.1.9e 1 − 0.4)n u(n) H e jω  = = ∞ X (n)e h=−∞ − j nω = ∞ X n − j nω .phaH.4n e− j nω = 2006 1 1 + − j ω 1 − 0. h(n) = (0.6 .[0.9*exp(-j*w)+0.9*exp(-j*w)).4 0.  The magnitude and phase response plots of H e j ω are shown in Figure 3./(1-0. close all.’FontSize’./EPSFILES/P0311d.5)n+(0.4)^n) u(n).5).6 −0.’defaultfigurepaperposition’.’FontSize’. plot(w/pi.’YTick’.’FontSize’.2 0 ω/π Figure 3.5)^n+(0.magtick).5 e 0=0 − jω + 2 − 0.9e− j ω + 0.6.LFS). ylabel(’Degrees’. magtick = [0:0. phaH = angle(H)*180/pi. set(gca.’FontSize’.27.1. xlabel(’\omega / \pi’.4 n n 0.2*exp(-j*2*w)).5e 1 − 0.2 0 ω/π 0.1.8 1 0.2 0. magtick = [-180:60:180].’XTick’. 1*pi)))+ % 0.phaH.5) × cos(0.25-cos(w-(0. set(gca.6 −0.6 0.4 0.TFS). magtick = [0:0. title([’Phase response’].8 −0.’P0311e’).’FontSize’..25-cos(w+(0.’LineWidth’.5|n| e− j (ω+0. ylabel(’|H|’.’FontSize’.1.1.5|n| e− j 0.4 −0.1π ) 1.5|n| e j 0.magH.75*ones(size(w)) .5*0.’FontSize’. 0.11e plots 0.5)^|n|*cos(0.2).wtick).1πn " ∞ # ∞ ∞ X X X  1 H e jω = (n)e− j nω = . w = [-300:300]*pi/300.5:3].8 −0. phaH = angle(H)*180/pi..25-cos(w-(0.[0.2 0 ω/π 0.1*pi))) clc.8 1 Phase response:h(n) = (0. plot(w/pi.1.1 π n) Degrees |n| 180 120 60 0 −60 −120 −180 −1 −0.wtick.75*ones(size(w)).5|n| e− j (ω−0.0./EPSFILES/P0311e.8 1 0.5). print -deps2 .TFS). axis([-1 1 0 3]).2:1].6 .1*pi)))+. h(n) = (0.2 0./(1. subplot(2.’NumberTitle’./(1.2 Figure 3.1 π n) 3 2.1). |H| Magnitude response:h(n) = (0.’Name’.5*0.1π)n + . set(Hf_1. title([’Magnitude response’]./(1.’off’.  The magnitude and phase response plots of H e j ω are shown in Figure 3.3]).1π n) = 12 0.6.1*pi))). magtick = [-180:60:180].’FontSize’.5)|n| × cos(0.28: Problem P3.’FontSize’.4 0.2006 Solutions Manual for DSP using Matlab (2nd Edition) 101 5. % H(w) = 0.LFS). wtick = [-1:0.25-cos(w+(0.’YTick’.2:1]. ylabel(’Degrees’.25 − cos(ω − 0.5 0 −1 −0.’FontSize’./(1. set(0.5*0. set(gca.75*ones(size(w)) .5 2 1.6 −0.5)|n| cos (0.25 − cos(ω + 0. xlabel(’\omega / \pi’.’XTick’. plot(w/pi. H = 0.1πn + 12 0. close all.1.5 1 0.2 0 ω/π 0.5).1*pi*n).75 0.1π ) Matlab script: % P0311e: h(n) = (0. axis([-1 1 -180 180]).’defaultfigurepaperposition’.4 −0. subplot(2.28.’XTick’.’LineWidth’. Hf_1 = figure.LFS).5 × 0. set(gca.5 × 0.LFS).magtick)..1π)n 2 h=−∞ 0=−∞ 0=−∞ = 0.75 + 1. xlabel(’\omega / \pi’.LFS). magH = abs(H).75*ones(size(w)).’YTick’. wtick = [-1:0.5*0.magtick). 12 Let x(n) = A cos(ω0 n + θ0 ) be an input sequence to an LTI system described by the impulse response h(n).Solutions Manual for DSP using Matlab (2nd Edition) 102 2006 P3. Then the output sequence y(n) is given by y(n) = h(n) ∗ x(n) = A ∞ X h=−∞ (k) cos[ω0 (n − k) + θ0 ] ∞ ∞ A X A X (k) exp [ j ω0 (n − k) + θ0 ] + (k) exp [− j ω0(n − k) − θ0 ] 2 h=−∞ 2 h=−∞ " ∞ # " ∞ # A j θ0 X A − j θ0 X − j ω0 k j ω0 n j ω0 k = e (k)e + e (k)e e e− j ω0 n 2 2 h=−∞ h=−∞ =   A j θ0 A e H e j ω0 e j ω0 n + e− j θ0 H ∗ e j ω0 e− j ω0 n 2 2  j ∠ H (e j ω 0 ) j ω n  A j θ0 A jω j ω0 = e |H e |e e 0 + e− j θ0 |H e j ω0 |e− j ∠H (e 0 ) e− j ω0 n 2 2          A j ω0 | exp j ω0 n + j θ0 + j ∠H e j ω0 + exp − j ω0 n + j θ0 + j ∠H e j ω0 = |H e 2    = A|H e j ω0 | cos ω0 n + j θ0 + j ∠H e j ω0 = .  The magnitude and phase response plots of H e j ω are shown in Figure 3. close all.5π n + 60◦ ) + 2 sin (0. % Hf_1 = figure.5{\pi}n + \pi/3) + 2sin(0.’FontSize’. axis([-22 22 -5 5]).LFS). w2 = 0.TFS).3π n).’FontSize’. set(Hs.1. phaH2 = angle(H2).’defaultfigurepaperposition’../EPSFILES/P0313a. title(’Output sequence y(n) for h(n) = (0.3*pi*n).29: Problem P3.6.29.’FontSize’.LFS). w1 = 0.19*w2/(1.81-1. subplot(2. The input to the system h(n) = (0.’markersize’. Hs = stem(n. xlabel(’n’.’markersize’.3]).’NumberTitle’. set(0.9)^{|n|}’.5*pi.9)|n| is x(n) = 3 cos (0.1). H2 = 0.19*w1/(1. Hs = stem(n.2).2).1. ylabel(’y(n)’.y. title([’Input sequence x(n): 3*cos(0. set(Hs.5*pi*n+pi/3)+2*sin(0. The steady-state response y(n) is computed using Matlab.13 Sinusoidal steady-state responses 1.e.’filled’).LFS).’off’.8*cos(w1)). ylabel(’x(n)’. % P0313a: x(n) = 3*cos(0. axis([-22 22 -5 5]).’P0313a’)... phaH1 = angle(H1).9)^|n| clc.5πn + π/3) + 2sin(0.3*pi.5*pi*n+pi/3)+2*sin(0. 2*magH2*cos(w2*n-pi/2+phaH2).0.LFS).3*pi*n-pi/2) % h(n) = (0. H1 = 0. i. set(Hf_1. Input sequence x(n): 3*cos(0. % x(n) = 3*cos(0.13a plots 10 .5*pi*n+pi/3)+2*cos(0. ’FontSize’.x.81-1.3{\pi}n)’].’Name’.9)|n| y(n) 5 0 −5 −20 −15 −10 −5 0 5 n Figure 3. y = 3*magH1*cos(w1*n+pi/3+phaH1)+.’FontSize’.2006 Solutions Manual for DSP using Matlab (2nd Edition) 103 P3. x = 3*cos(0.’FontSize’.8*cos(w2)).2)... magH2 = abs(H2).3πn) x(n) 5 0 −5 −20 −15 −10 −5 0 5 10 15 20 15 20 n Output sequence y(n) for h(n) = (0.3*pi*n). magH1 = abs(H1)..’filled’). subplot(2. print -deps2 . % n = [-20:20]. xlabel(’n’.TFS).[0. % Hf_1 = figure.5*pi*n+pi/3)+2*sin(0. The input to the system h(n) = sinc (0. set(0.TFS). magH2 = abs(H2).’filled’).y.1.LFS). ’FontSize’. axis([-22 22 -5 5]).w1). print -deps2 .’P0313b’).5*pi*n+pi/3)+2*cos(0. ylabel(’x(n)’.1).13b plots 10 15 20 .’FontSize’.30: Problem P3. subplot(2. phaH2 = angle(H2).x. % n = [-20:20].’markersize’. xlabel(’n’. set(Hf_1.w2). title(’Output sequence y(n) for h(n) = sinc(0.2*n). [h2. w2 = 0. H2 = dtft(h.e... % x(n) = 3*cos(0.’filled’).2*n)*[u(n+20)-u(n-20)] clc.3*pi*n). Hs = stem(n. axis([-22 22 -5 5]).’FontSize’. Hs = stem(n. close all.5*pi. title([’Input sequence x(n): 3*cos(0.n2] = stepseq(20.2).’markersize’.’Name’.’FontSize’.’FontSize’.3*pi*n-pi/2) % h(n) = sinc(0.3]). i.n2). where sinc 0 = 1..n.. set(Hs.20). x = 3*cos(0.n3] = sigadd(h1. phaH1 = angle(H1). [h3.1.2).5{\pi}n + \pi/3) + 2sin(0. The steadystate response y(n) is computed using Matlab. Input sequence x(n): 3*cos(0.2n) [u (n + 20) − u (n − 20)] . magH1 = abs(H1). ’FontSize’. w1 = 0.3*pi. % P0313b: x(n) = 3*cos(0. subplot(2.Solutions Manual for DSP using Matlab (2nd Edition) 104 2006 2.-20. y = 3*magH1*cos(w1*n+pi/3+phaH1)+2*magH2*cos(w2*n-pi/2+phaH2). H1 = dtft(h.*h3. n = n3.’defaultfigurepaperposition’. set(Hs.LFS).5*pi*n+pi/3)+2*sin(0.-20.LFS).20).2).’NumberTitle’.2 n)[u(n+20) − u(n−20)] y(n) 5 0 −5 −20 −15 −10 −5 0 5 n Figure 3.[0. [h1.30.2 n)[u(n+20) .3*pi*n).6.  The magnitude and phase response plots of H e j ω are shown in Figure 3.LFS).-h2.n1.n..0.’off’. ylabel(’y(n)’../EPSFILES/P0313b.TFS).5πn + π/3) + 2sin(0.u(n-20)]’.3{\pi}n)’]. h = sinc(0. xlabel(’n’..3πn) x(n) 5 0 −5 −20 −15 −10 −5 0 5 10 15 20 n Output sequence y(n) for h(n) = sinc(0.n1] = stepseq(-20. The input to the system h(n) = sinc (0.0.2*n)*[u(n)-u(n-40)] clc. w2 = 0.n3] = sigadd(h1. set(0.40). i.LFS). subplot(2.y. phaH2 = angle(H2). title(’Output sequence y(n) for h(n) = sinc(0.’defaultfigurepaperposition’.TFS).’P0313c’).1. close all.5πn + π/3) + 2sin(0. phaH1 = angle(H1).LFS).3{\pi}n)’].5*pi*n+pi/3)+2*sin(0. ’FontSize’.2*n3).u(n-40)]’.2).1).w1).n3.3]).31: Problem P3.n2).0.’FontSize’.LFS).’markersize’. % n = [-20:20].3*pi. % x(n) = 3*cos(0. set(Hs.31.e.3πn) x(n) 5 0 −5 −20 −15 −10 −5 0 5 10 15 20 n Output sequence y(n) for h(n) = sinc(0.. [h2.5*pi*n+pi/3)+2*cos(0.3*pi*n-pi/2) % h(n) = sinc(0.  The magnitude and phase response plots of H e j ω are shown in Figure 3.TFS).-h2. xlabel(’n’. [h3. set(Hf_1.2). axis([-22 22 -5 5]).’FontSize’. xlabel(’n’./EPSFILES/P0313c. print -deps2 .5*pi.. ’FontSize’. x = 3*cos(0.n1. % P0313c: x(n) = 3*cos(0.’FontSize’.3*pi*n). magH1 = abs(H1)...5*pi*n+pi/3)+2*sin(0.2). y = 3*magH1*cos(w1*n+pi/3+phaH1)+2*magH2*cos(w2*n-pi/2+phaH2). ylabel(’y(n)’.w2). Hs = stem(n. The steady-state response y(n) is computed using Matlab.. Hs = stem(n. [h1.’filled’). H2 = dtft(h.’NumberTitle’. magH2 = abs(H2). h = sinc(0.5{\pi}n + \pi/3) + 2sin(0.. title([’Input sequence x(n): 3*cos(0.n3. w1 = 0.2n) [u(n) − u (n − 40)].1.2 n)[u(n) − u(n−40)] y(n) 5 0 −5 −20 −15 −10 −5 0 5 n Figure 3. Input sequence x(n): 3*cos(0.’FontSize’..13c plots 10 15 20 .n2] = stepseq(40.2 n)[u(n) . % Hf_1 = figure. axis([-22 22 -5 5]).’Name’. set(Hs. ylabel(’x(n)’.’filled’).*h3.[0. subplot(2.0.’markersize’.40).3*pi*n). H1 = dtft(h.’off’.n1] = stepseq(0.2006 Solutions Manual for DSP using Matlab (2nd Edition) 105 3.LFS).6.x. 3πn) x(n) 10 0 −10 −20 −15 −10 −5 0 5 10 15 20 n Output sequence y(n) for h(n) = [(0..1. % Hf_1 = figure. Hs = stem(n. The input to the system h(n) = (0.’filled’).’FontSize’.4)^n] u(n)]’. title([’Input sequence x(n): 3*cos(0.TFS). i.3]). w2 = 0.5{\pi}n + \pi/3) + 2sin(0.LFS).2*exp(-j*2*w1)).’P0313d’).9*exp(-j*w2)+0.2).’Name’.5*pi*n+pi/3)+2*sin(0.*u(n) clc. set(0.. phaH2 = angle(H2).1.x.’FontSize’..4)n] u(n)] y(n) 10 0 −10 −20 −15 −10 −5 0 5 n Figure 3. y = 3*magH1*cos(w1*n+pi/3+phaH1)+2*magH2*cos(w2*n-pi/2+phaH2). The steady-state response y(n) is computed using Matlab.5)^(n)+(0. ’FontSize’.5)^n+(0. Hs = stem(n./(1-0.[0.5πn + π/3) + 2sin(0.0. w1 = 0.e.’filled’).9*exp(-j*w1)+0. magH2 = abs(H2). axis([-22 22 -10 10]).TFS).’markersize’..’defaultfigurepaperposition’. Input sequence x(n): 3*cos(0. set(Hf_1.13d plots 10 15 20 .6.LFS). phaH1 = angle(H1).9*exp(-j*w1)).LFS). H1 = (2-0.3*pi*n-pi/2) % h(n) = ((0.9*exp(-j*w2)).3*pi*n). ylabel(’x(n)’. ’FontSize’./(1-0. close all. xlabel(’n’. magH1 = abs(H1). H2 = (2-0.’FontSize’.4)n u(n).5)n+(0. title(’Output sequence y(n) for h(n) = [(0.5*pi.3{\pi}n)’].’off’.3*pi*n). subplot(2. subplot(2.2). print -deps2 . % n = [-20:20].’NumberTitle’.4)^(n)).5*pi*n+pi/3)+2*cos(0.y.32. x = 3*cos(0.Solutions Manual for DSP using Matlab (2nd Edition) 106 2006   4. set(Hs. ylabel(’y(n)’.. % x(n) = 3*cos(0.LFS). axis([-22 22 -10 10]).  The magnitude and phase response plots of H e j ω are shown in Figure 3.. xlabel(’n’.2). % P0313d: x(n) = 3*cos(0.5)n + (0.’FontSize’.5*pi*n+pi/3)+2*sin(0. set(Hs.32: Problem P3.3*pi./EPSFILES/P0313d.1)..’markersize’.2*exp(-j*2*w2)). 25-cos(w2+(0.’defaultfigurepaperposition’.5{\pi}n + \pi/3) + 2sin(0.3*pi.2). The steady-state response y(n) is computed using Matlab.TFS).’markersize’. subplot(2.5*0.. clc. H2 = 0. set(Hs.3{\pi}n)’].’off’. set(Hf_1..33: Problem P3.1{\pi}n)] u(n)]’.5)^|n|*cos(0.5*0...  The magnitude and phase response plots of H e j ω are shown in Figure 3.75*w1/(1.LFS).’filled’). % P0313e: x(n) = 3*cos(0. w1 = 0. Hs = stem(n.1*pi)))+./EPSFILES/P0313e.75*w2/(1.13e plots 10 15 20 .6.2006 Solutions Manual for DSP using Matlab (2nd Edition) 107 5.5*pi*n+pi/3)+2*sin(0. ylabel(’x(n)’.1*pi*n). print -deps2 .5*pi*n+pi/3)+2*sin(0.75*w1/(1.1π n).LFS).’P0313e’).25-cos(w1-(0.’FontSize’. phaH1 = angle(H1).[0. % x(n) = 3*cos(0.25-cos(w1+(0. ylabel(’y(n)’. Hs = stem(n...5*pi*n+pi/3)+2*cos(0. Input sequence x(n): 3*cos(0.1).5)|n| cos (0. w2 = 0.x.y..2). axis([-22 22 -6 6]).’NumberTitle’.1πn)] u(n)] y(n) 5 0 −5 −20 −15 −10 −5 0 5 n Figure 3. xlabel(’n’.TFS).1.LFS).1*pi)))+.’FontSize’.LFS).2). ’FontSize’.. subplot(2. i.1*pi))).1. title([’Input sequence x(n): 3*cos(0.e.3*pi*n). magH2 = abs(H2).75*w2/(1. x = 3*cos(0.5)^{|n|}cos(0.’FontSize’. ’FontSize’...3]).’Name’. title(’Output sequence y(n) for h(n) = (0. set(0.5*0.’FontSize’.3*pi*n). xlabel(’n’.5πn + π/3) + 2sin(0.5*0. % Hf_1 = figure. y = 3*magH1*cos(w1*n+pi/3+phaH1)+2*magH2*cos(w2*n-pi/2+phaH2). phaH2 = angle(H2). 0.3πn) x(n) 5 0 −5 −20 −15 −10 −5 0 5 10 15 20 n |n| Output sequence y(n) for h(n) = (0. axis([-22 22 -6 6]).’markersize’.33.3*pi*n-pi/2) % h(n) = (0.5*pi. 0.’filled’). magH1 = abs(H1).1*pi))). close all.. set(Hs. H1 = 0.25-cos(w2-(0. % n = [-20:20].0.5) cos(0. The input to the system h(n) = (0. 14 An ideal lowpass filter is described in the frequency-domain by  |ω| ≤ ωc 1 · e− j αω .2): Z ∞ Z ωc Z ωc   1 1 1 −1 jω j ω j nω − j αω j nω h d (n) = F Hd (e ) = Hd (e )e dω = e e dω = e j (n−α)ω dω 2π −∞ 2π −ωc 2π −ωc . The ideal impulse response h d (n) using the IDTFT relation (3. 1.Solutions Manual for DSP using Matlab (2nd Edition) 108 2006 P3. ωc < |ω| ≤ π where ωc is called the cutoff frequency and α is called the phase delay. jω Hd (e ) = 0. ω 1 e j (n−α)ω . . c sin[ωc (n − α)] = = 2π j (n − α) . alpha = 20.[-0. 0 ≤ n ≤ N − 1 = π(n − α) 0.’FontSize’. set(Hs.’FontSize’.3 0.0.LFS). Hs = stem(n.1 −0. Truncated Impulse Response h(n) 0. axis([-2 42 -0.’P0314b’)..5.h.5π . h = 2*fc*sinc(2*fc*(n-alpha)).5 h(n) 0./EPSFILES/P0314b.−ωc π(n − α) 2.otherwise clc. and ωc = 0. wc = 0.’YTick’. fc = wc/(2*pi).0 <= n <= N-1 % = 0 .2:0.6]). set(gca.’filled’).’off’. h(n) = h_d(n) . set(0. ylabel(’h(n)’.’Name’.[0. % Hf_1 = figure. 0≤n ≤ N −1 h d (n). set(Hf_1.’markersize’. otherwise  0.6 0.2 0 5 10 15 20 25 n Figure 3. otherwise for N = 41.’NumberTitle’.14b plot 30 35 40 . xlabel(’n’.2 0. α = 20.2]). close all.6]). % n = [0:40].1:0.’FontSize’.5*pi.TFS).’defaultfigurepaperposition’.4 0. Matlab script: Matlab script: % P0314b: Truncated Ideal Lowpass Filter.34: Problem P3. Plot of the truncated impulse response: h(n) =    sin[ωc (n − α)] . print -deps2 .LFS).2 0.2). The truncated impulse response plot of h d (n) is shown in Figure 3. title(’Truncated Impulse Response h(n)’.34.1 0 −0. ’off’.2]).2 0 0. close all.LFS). plot(w/pi.’FontSize’.0.’XTick’.6 |Hd| 0.’XTick’.6 ω/π Phase of H (ejω) d 1.ytick).’YTick’.’FontSize’. phaH = angle(H).’YTick’.. ytick = [0:0. magH = abs(H). magtick = [-180:60:180].6 Figure 3. set(Hf_1. set(gca.TFS).’FontSize’.n.magH.2].1. magtick = [-180:60:180].TFS).magtick). ylabel(’Degrees’.6 0.LFS).2.6 Magnitude of H (ejω) −0.2006 Solutions Manual for DSP using Matlab (2nd Edition) 109  3.’FontSize’. H_d(K/2+1:3*K/2+1) = exp(-j*alpha*w(K/2+1:3*K/2+1)). H_d = zeros(1.6 1 d Degrees −0. set(gca.’FontSize’. subplot(2. ylabel(’|H|’. % K = 500. plot(w/pi.2.2 1 180 120 60 0 −60 −120 −180 −1 −0.2 0 0.magH_d.6.4).wtick). Plot of the frequency response function H e j ω and comparison with the ideal lowpass filter response  Hd e j ω : Matlab script: % P0314c: Freq Resp of truncated and ideal impulse responses for lowpass filter clc.phaH_d*180/pi. Hf_1 = figure.2 ω/π 0.’FontSize’. title(’Magnitude of H(e^{j\omega})’.phaH*180/pi.’LineWidth’.w).LFS).2]).14c plots −0.5). axis([-1 1 0 1.6 ω/π 1 180 120 60 0 −60 −120 −180 −1 −0.1.2 0. The frequency responses are shown in Figure 3.’FontSize’. axis([-1 1 0 1. xlabel(’\omega / \pi’.5). set(gca.LFS).’YTick’.5). title(’Phase of H(e^{j\omega})’.2 ω/π . ylabel(’|H_d|’.length(w)). set(gca.’LineWidth’.’NumberTitle’.2). xlabel(’\omega / \pi’. plot(w/pi.’FontSize’. magH_d = abs(H_d). Magnitude of H(ejω) Phase of H(ejω) Degrees |H| 1 0.3).’FontSize’./EPSFILES/P0314c.8 0.35: Problem P3. xlabel(’\omega / \pi’.’XTick’.2. xlabel(’\omega / \pi’. plot(w/pi.’XTick’.2 0 0.6 1 0.2:1.’P0314c’). set(gca. ylabel(’Degrees’.magtick).5 0 −1 −0.6 −0.2 1 0. phaH_d = angle(H_d).4:1 0]). set(gca.35 from which we observe that the truncated response is a smeared or blurred version of the ideal response.’FontSize’.wtick). set(gca. title(’Phase of H_d(e^{j\omega})’.wtick).1).wtick).’LineWidth’.5).1.’XTick’. subplot(2. print -deps2 . subplot(2.TFS).[0.’FontSize’.2 0 −1 −0. subplot(2.LFS).2 0 0. title(’Magnitude of H_d(e^{j\omega})’.’Name’. set(gca.’LineWidth’.wtick). set(0. w = [-K:K]*pi/K.4 0.1.2.LFS). H = dtft(h.LFS).3]).’defaultfigurepaperposition’.TFS). wtick = sort([-1:0.LFS).’FontSize’. ’FontSize’. h(n) = h_d(n) .2 −0.LFS).1 −0.3 0.’markersize’.2 0.h. alpha = 20.5 0. title(’Truncated Impulse Response h(n)’.4 0.LFS). ωc < |ω| ≤ π jω Hd (e ) = |ω| ≤ ωc 0.TFS).5. where ωc is called the cutoff frequency and α is called the phase delay.[-0..’filled’). h(n) Truncated Impulse Response h(n) 0.6]). 0 ≤ n ≤ N − 1 = π(n − α) π(n − α) 0.’NumberTitle’.4 0 5 10 15 20 25 n Figure 3. 0≤n ≤ N −1 h d (n).’FontSize’. print -deps2 .15 An ideal highpass filter is described in the frequency-domain by  1 · e− j αω . % Hf_1 = figure.0 <= n <= N-1 % = 0 . % n = [0:40].3 −0.’P0315b’). set(0. set(gca.1 0 −0.0.’defaultfigurepaperposition’. The truncated impulse response plot of h d (n) is shown in Figure 3. Hs = stem(n. h = sinc(n-alpha)-2*fc*sinc(2*fc*(n-alpha)).’off’. axis([-2 42 -0.2).36. otherwise for N = 31.[0. α = 15. set(Hf_1.6 0. fc = wc/(2*pi). ylabel(’h(n)’.15b plot 30 35 40 .’Name’.otherwise clc.5π .4 0.36: Problem P3.Solutions Manual for DSP using Matlab (2nd Edition) 110 2006 P3.’YTick’. xlabel(’n’.5*pi. close all. wc = 0.6]).2): Z ∞ Z −ωc Z π   1 1 1 −1 jω j ω j nω − j αω j nω Hd (e )e dω = e e dω + e− j αω e j nω dω h d (n) = F Hd (e ) = 2π −∞ 2π −π 2π ωc Z π Z ω 1 1 sin[π(n − α)] sin[ωc (n − α)] j (n−α)ω = e dω − e j (n−α)ω dω = − 2π −π 2π −ωc π(n − α) π(n − α) 2.1:0.’FontSize’. Matlab script: Matlab script: % P0315b: Ideal Highpass Filter.4:0. Plot of the truncated impulse response: h(n) =    sin[π(n − α)] sin[ωc (n − α)] − . set(Hs. and ωc = 0. The ideal impulse response h d (n) using the IDTFT relation (3.2])./EPSFILES/P0315b. otherwise  0. 1. 2 0 0. plot(w/pi.LFS).’XTick’.TFS).’XTick’.’YTick’.’LineWidth’. Magnitude of H(ejω) Phase of H(ejω) Degrees |H| 1 0.2.’NumberTitle’. subplot(2.5). Plot of the frequency response function H e j ω and comparison with the ideal lowpass filter response  Hd e j ω : Matlab script: % P0315c: Freq Resp of truncated and ideal impulse responses for highpass filter clc.LFS).2.2 0 0. plot(w/pi.1.3]). H_d = zeros(1.6 0.’YTick’. title(’Magnitude of H(e^{j\omega})’.phaH_d*180/pi. set(0. H = dtft(h.TFS).4 0.magH.set(gca. set(gca.LFS).2).2 0 0.’FontSize’. title(’Phase of H_d(e^{j\omega})’. xlabel(’\omega / \pi’.’FontSize’.5).2 ω/π 0. phaH_d = angle(H_d). axis([ -1 1 0 1. magH = abs(H). title(’Phase of H(e^{j\omega})’./EPSFILES/P0315c.’YTick’. w = [-K:K]*pi/K. ylabel(’|H|’. set(gca.’FontSize’. Hf_1 = figure.5).ytick).wtick).2 0 0.6 |Hd| 0.6 ω/π Phase of H (ejω) d 1.wtick). axis([-1 1 0 1.’FontSize’. magtick = [-180:60:180].LFS).magH_d.wtick).2 ω/π .’defaultfigurepaperposition’.’P0315c’).’FontSize’. H_d(3*K/2+1:end) = exp(-j*alpha*w(3*K/2+1:end)).TFS).2. title(’Magnitude of H_d(e^{j\omega})’. K = 500. ylabel(’|H_d|’.6 1 0.’FontSize’. plot(w/pi. H_d(1:K/2+1) = exp(-j*alpha*w(1:K/2+1)).5). set(gca.2 1 180 120 60 0 −60 −120 −180 −1 −0.3). set(gca.2006 Solutions Manual for DSP using Matlab (2nd Edition) 111  3.5 0 −1 −0.’LineWidth’.wtick). wtick = sort([-1:0.2.’FontSize’. subplot(2. magH_d = abs(H_d).[0.2 1 0..0. xlabel(’\omega / \pi’. The frequency responses are shown in Figure 3.6 −0. phaH = angle(H). print -deps2 . set(Hf_1.1.8 0.LFS).’FontSize’.37: Problem P3.magtick).’XTick’.4:1 0]).’FontSize’.’XTick’.4).6 ω/π 1 180 120 60 0 −60 −120 −180 −1 −0.6 Figure 3. magtick = [-180:60:180].6 1 d Degrees −0.15c plots −0. set(gca. xlabel(’\omega / \pi’. ytick = [0:0.w). subplot(2.2]). ylabel(’Degrees’. ylabel(’Degrees’.’off’.length(w)).’FontSize’.’LineWidth’.wtick). set(gca. subplot(2.1).phaH*180/pi.2:1.LFS).6 Magnitude of H (ejω) −0.’XTick’. xlabel(’\omega / \pi’.TFS).2 0. close all.magtick).2 0 −1 −0.’LineWidth’.LFS).1.1.37 from which we observe that the truncated response is a smeared or blurred version of the ideal response. plot(w/pi.’FontSize’.’Name’.n.2].6.2]).’FontSize’.LFS). set(gca. 1. w = reshape(w.length(a)). den = a*exp(-j*l’*w).a. 2006 .112 Solutions Manual for DSP using Matlab (2nd Edition) P3. H = num./den.length(b)). function [H] = freqresp(b.w) % H = frequency response array evaluated at w frequencies % b = numerator coefficient array % a = denominator coeeficient array (a(1) = 1) % w = frequency location array % b = reshape(b.1.w) % Frequency response function from difference equation % [H] = freqresp(b.length(w)).1.16 Matlab function freqresp.a. l = 0:length(a)-1. num = b*exp(-j*m’*w). a = reshape(a. m = 0:length(b)-1. ’LineWidth’. set(gca.’XTick’.1.LFS). set(gca.2 0.1. ylabel(’|H|’.magtick).2:1. wtick = [-1:0. plot(w/pi. axis([-1 1 -220 220]).4 −0. The frequency responses are shown in Figure 3.2:1]. [H] = freqresp(b.’FontSize’.2 Figure 3.2 0. print -deps2 .’FontSize’.2]).8 1 0.magtick).wtick).’NumberTitle’.LFS).’XTick’. ylabel(’Degrees’. subplot(2. % Hf_1 = figure.phaH.’P0317a’).2 0.4 −0.’FontSize’.2 0.w).LFS).6 0.6 0. % w = [-300:300]*pi/300.5).TFS).2 0.’YTick’.6 −0.2].8 0.’off’.’FontSize’. subplot(2. magH = abs(H). phaH = angle(H)*180/pi.4 0.5). plot(w/pi.8 1 Degrees Phase Response 180 120 60 0 −60 −120 −180 −1 −0.8 −0.2).2 0 ω/π 0. a = [1]. xlabel(’\omega / \pi’./EPSFILES/P0317a. b = [0.6 0.8 −0.’Name’.4 0.6 −0.’LineWidth’.2 1 0.4 0. set(Hf_1. magtick = [0:0.2 0 −1 −0.1. set(gca..1. y(n) = 1 5 P4 m=0 Matlab script: x(n − m): % P0317a: y(n) = (1/5) sum_{0}^{4} x(n-m) clc. axis([-1 1 0 1. xlabel(’\omega / \pi’.TFS).’YTick’.magH.17 Computation and plot of the frequency response H (e j ω ) using Matlab for each of the following systems: 1. title(’Phase Response ’.2].2:1].2 0 ω/π 0.LFS). set(gca.’FontSize’.2006 Solutions Manual for DSP using Matlab (2nd Edition) 113 P3.17a .1). title([’Magnitude response’]. wtick = [-1:0. close all.38 |H| Magnitude response 1.’FontSize’.38: Frequency response plots in Problem P3.wtick). magtick = [-180:60:180].a. y(n) = x(n) − x(n − 2) + 0.1.’off’. ylabel(’|H|’. print -deps2 .8 1 Degrees Phase response 180 120 60 0 −60 −120 −180 −1 −0.magH. title([’Phase response’].’YTick’.Solutions Manual for DSP using Matlab (2nd Edition) 114 2006 2.magtick)..’FontSize’.1.’FontSize’.6 −0.39: Frequency response plots in Problem P3. a = [1 -0.2 0 ω/π 0.5). plot(w/pi. subplot(2. b = [1 0 -1]. wtick = [-1:0.9025].LFS).4 0.6 0. magtick = [-180:60:180].9025*y(n-2) clc.’LineWidth’.1.8 −0. ylabel(’Degrees’. phaH = angle(H)*180/pi.w).6 −0.2 0 ω/π 0.magtick).a. wtick = [-1:0.5). set(Hf_1.LFS).’FontSize’. magtick = [0:5:25].95y(n − 1) − 0. set(gca.1.17b .2:1]. plot(w/pi.wtick).4 −0.’XTick’. subplot(2. xlabel(’\omega / \pi’.1).2 Figure 3.2).TFS).39 Magnitude response 25 |H| 20 15 10 5 0 −1 −0.4 0. title([’Magnitude response’].’FontSize’.’FontSize’.phaH.’Name’.LFS). xlabel(’\omega / \pi’.4 −0.LFS).’P0317b’). % w = [-300:300]*pi/300.TFS).8 1 0.2 0.wtick). The frequency responses are shown in Figure 3.2:1]. % Hf_1 = figure.9025y(n − 2) Matlab script: % P0317b: y(n) = x(n)-x(n-2)+0.8 −0.95 0.’NumberTitle’.6 0. axis([-1 1 -200 200]).95*y(n-1)-0. magH = abs(H).’YTick’.’FontSize’./EPSFILES/P0317b.’LineWidth’. set(gca. set(gca. [H] = freqresp(b. axis([-1 1 0 25]). close all.’XTick’. set(gca. 2 0 −1 −0.’FontSize’.1. wtick = [-1:0. axis([-1 1 -200 200]).’off’.TFS).’Name’. [H] = freqresp(b.6 0. plot(w/pi.2:1].4 0. subplot(2. % Hf_1 = figure.2 1 0.’FontSize’.5).17c .4 0. set(gca.8 −0.1.1.’YTick’.wtick).4 0.40: Frequency response plots in Problem P3.’FontSize’. magtick = [0:0.2 Figure 3. title([’Magnitude response’].a.2).w). set(gca.9025]. % w = [-300:300]*pi/300.phaH.’LineWidth’.9025*y(n-2) clc.40 |H| Magnitude response 1.2:1].’FontSize’.8 −0.95*y(n-1)-0.magtick). subplot(2.LFS). close all.4].’FontSize’.TFS).6 −0.6 0.8 1 0. set(Hf_1.magH.4])./EPSFILES/P0317c. phaH = angle(H)*180/pi.4 1.5)..’P0317c’).6 0. title([’Phase response’]. ylabel(’|H|’. b = [1 -1 1]. The frequency responses are shown in Figure 3.’YTick’.LFS). axis([-1 1 0 1.’FontSize’.2 0 ω/π 0. wtick = [-1:0.1).LFS). set(gca. magH = abs(H).2 0 ω/π 0.wtick).magtick). plot(w/pi.6 −0.2:1.8 1 Degrees Phase response 180 120 60 0 −60 −120 −180 −1 −0. ylabel(’Degrees’.8 0.1. a = [1 -0.’NumberTitle’.95 0. xlabel(’\omega / \pi’. y(n) = x(n) − x(n − 1) + x(n − 2) + 0. print -deps2 . magtick = [-180:60:180].2 0. set(gca.LFS).’XTick’.2006 Solutions Manual for DSP using Matlab (2nd Edition) 115 3. xlabel(’\omega / \pi’.’XTick’.4 −0.95y(n − 1) − 0.9025y(n − 2) Matlab script: % P0317c: y(n) = x(n)-x(n-1)+x(n-2)+0.4 −0.’LineWidth’. 5625 1.8 −0. title(’Phase response’.’off’.1314*y(n-1).1.64y(n − 2) Matlab script: % P0317d: y(n) = x(n)-1.4 0.’NumberTitle’.’FontSize’.17d . wtick = [-1:0.TFS).4 −0. The frequency responses are shown in Figure 3.2:1].6 0.5625x(n − 2) + 1.6].Solutions Manual for DSP using Matlab (2nd Edition) 116 2006 4.0. ylabel(’Degrees’.1314y(n − 1) − 0.1314 0.’FontSize’./EPSFILES/P0317d.LFS).7678*x(n-1)+1. close all..TFS). ylabel(’|H|’.LFS).6 0.2 0.’P0317d’).’XTick’.5).5625].wtick). xlabel(’\omega / \pi’. title([’Magnitude response’].phaH. % Hf_1 = figure. magtick = [1.7678x(n − 1) + 1.2 0 ω/π 0.’YTick’. [H] = freqresp(b. wtick = [-1:0.5).a. % w = [-300:300]*pi/300. set(gca.8 1 Degrees Phase response 180 120 60 0 −60 −120 −180 −1 −0.wtick). subplot(2.1). set(gca.’FontSize’.’Name’.’FontSize’.w). a = [1 -1.’FontSize’. magH = abs(H).41: Frequency response plots in Problem P3. magtick = [-180:60:180].’XTick’. subplot(2.64].2 Figure 3. print -deps2 .2:1].magtick). xlabel(’\omega / \pi’.41 Magnitude response |H| 1. axis([-1 1 -200 200]).7678 1.’FontSize’.’LineWidth’.LFS).4 −0. b = [1 -1.4 0.’LineWidth’. plot(w/pi. y(n) = x(n) − 1.02:1.8 1 0.1. plot(w/pi.1.1.LFS).magH.2 0 ω/π 0.6 −0. set(gca.5624 −1 −0.2).6 −0.64*y(n-2) clc.5625*x(n-2)+1.8 −0.5625 1.5:0. set(Hf_1. phaH = angle(H)*180/pi. ’Name’.5) ^ l*y(n-l).8]).’XTick’. wtick = [-1:0. l = [0:5]. axis([-1 1 -180 180]).2 0 −1 −0.8 −0. close all. axis([-1 1 0 1.2 0 ω/π 0.6 0. ylabel(’|H|’. title([’Magnitude Response’].’NumberTitle’. wtick = [-1:0.’FontSize’. set(gca. set(gca.4 −0.’XTick’.5).’YTick’.’YTick’.2 0.8 1 Degrees Phase Response 180 120 60 0 −60 −120 −180 −1 −0. phaH = angle(H)*180/pi.8 −0.4 −0.’FontSize’.’FontSize’.8 1.4 0.5). % w = [-300:300]*pi/300. b = [1].8 0..LFS).2 1 0.a. plot(w/pi. xlabel(’\omega / \pi’.8].17e .wtick).LFS).’off’.2). ylabel(’Degrees’.2:1].5) ℓ 117 y (n − ℓ) % P0317e: y(n) = x(n)-sum _ {l = 1} ^ {5} (0.’P0317e’).TFS). magtick = [-180:60:180]./EPSFILES/P0317e.42 |H| Magnitude Response 1.42: Frequency response plots in Problem P3.8 1 0. print -deps2 .w).2 Figure 3.1.phaH.6 −0.1. magH = abs(H).’LineWidth’. a = 0.6 −0. plot(w/pi.magtick).wtick). set(gca. [H] = freqresp(b.2:1]. set(Hf_1.2006 Solutions Manual for DSP using Matlab (2nd Edition) 5. % Hf_1 = figure. xlabel(’\omega / \pi’.LFS).1.magH. magtick = [0:0. The frequency responses are shown in Figure 3. y(n) = x(n) − Matlab script: P5 ℓ=1 (0. set(gca.4 1.4 0.’LineWidth’.1.2 0 ω/π 0.’FontSize’.2:1.TFS). subplot(2.6 0.LFS). subplot(2.4 0.6 0.’FontSize’.6 1.magtick).^ l.’FontSize’.1). clc.5 . title([’Phase Response’]. y2.’FontSize’. print -deps2 .y1.4424 + 16. x = 5+10*(-1) .LFS).TFS).x). title(’Steady state response y_{ss}(n) for x(n) = 5+10(-1)^{n}’.ytick).’FontSize’. set(gca. The steady-state responses are shown in Figure 3.. ylabel(’y(n)’. set(Hs. magH = abs(H).’off’. title([’Output response y(n) using the filter function for x(n) = ’ .a.1).2). P3 P3 − j0   e− j 2πℓ m=0 e j0 jπ H e = P3 = 1.’FontSize’.*magH.1.8848(−1)n .’NumberTitle’. Hs = stem(n. [H] = freqresp(b.TFS)./EPSFILES/P0318a.43: Steady-state response plots in Problem P3.81^2 0 0. cos_term = cos(term1+term2).[0. xlabel(’n’. A = [5 10]. ’5+10(-1)^{n}’]. w = [0 pi]. n = [0:50].’YTick’.3]).’defaultfigurepaperposition’..43.w).0. Matlab script: % P0318a: y(n) = sum_{m=0}^{3} x(n-2m)-sum_{l=1}^{3} (0. set(Hf_1.’Name’. theta = [0 0].LFS). b = [1 0 1 0 1 0 1]. Hf_1 = figure.81) e ℓ=0 (0.’P0318a’).’filled’). phaH = angle(H).. set(gca. a = [1 0 0.6885 and H e = P3 m=0 = 1. pha = phaH+theta. y2 = filter(b.^ n. y1 = mag*cos_term. term2 = pha’*ones(1. axis([-1 51 -10 30]).1. set(Hs.2). subplot(2.length(n)). axis([-1 51 -10 30]).’markersize’..6885x(n) = 8.81) 2ℓ e− j 2ℓω 1..2). term1 = w’*n.’FontSize’..’filled’). xlabel(’n’.6885 2ℓ − j 0 2ℓ − j 2πℓ ℓ=0 (0.Solutions Manual for DSP using Matlab (2nd Edition) 118 2006 P3.81^6].81)^l y(n-2l) % x(n) = 5+10(-1) ^ n.81) e Hence the steady-state response is y(n) = 1. shift-invariant system is described by the difference equation y(n) = 3 X m=0 x (n − 2m) − 3 X ℓ=1 ℓ (0.’FontSize’. close all. y(n) Steady state response yss(n) for x(n) = 5+10(−1)n 25 20 15 10 5 0 −5 −10 0 5 10 15 20 25 30 35 40 45 50 n n y(n) Output response y(n) using the filter function for x(n) = 5+10(−1) 25 20 15 10 5 0 −5 −10 0 5 10 15 20 25 30 35 40 n Figure 3.81) y (n − 2ℓ) ⇒ H e jω  P3 = P3 m=0 e− j 2mω ℓ=0 (0. ylabel(’y(n)’.18a 45 50 .’markersize’. mag = A. ytick = [-10:5:25].LFS).a. ’FontSize’.81^4 0 0. x(n) = 5 + 10 (−1)n = 5 + 10 cos(nπ ): We need frequency responses at ω = 0 and ω = π . set(0.’YTick’.18 A linear. subplot(2.LFS). Hs = stem(n. clc.6.ytick). 5 0 0 5 10 15 20 25 30 35 40 45 50 45 50 n Output response y(n) using the filter function 2. term1 = w’*n.81) 2ℓ e− j 0 = 1.2).1).0.1.2).[0. magH = abs(H).5:2.5{\pi}n+\pi/2)’]. n = [0:50].’FontSize’.y2. a = [1 0 0. set(gca.’FontSize’.5]). xlabel(’n’.5*pi*n+pi/2).*magH. Hs = stem(n. clc./EPSFILES/P0318b.’defaultfigurepaperposition’.’FontSize’.5:2. mag = A. H e j0  = P3 P3 m=0 e− j 0 ℓ=0 (0.18b .81^4 0 0. set(gca.’YTick’.’Name’.5]). title([’SS response y_{ss}(n): x(n) = 1+cos(0.5 y(n) 2 1. term2 = pha’*ones(1.81) 2ℓ e− j πℓ =0 Hence the steady-state response is y(n) = 1. subplot(2.w). phaH = angle(H). ylabel(’y(n)’. Hs = stem(n. SS response yss(n): x(n) = 1+cos(0. print -deps2 .x).2006 Solutions Manual for DSP using Matlab (2nd Edition) 119 2.81^2 0 0. axis([-1 51 0 2. close all. axis([-1 51 0 2.81)^l y(n-2l) % x(n) = 1+cos(0. x = 1+cos(0. set(Hf_1.LFS).5 0 0 5 10 15 20 25 30 35 40 n Figure 3.5π n + π/2): We need responses at ω = 0 and ω = 0.LFS).’P0318b’).ytick).5].5*pi*n+pi/2).’filled’).TFS). w = [0 pi/2].2). xlabel(’n’. subplot(2. b = [1 0 1 0 1 0 1].44: Steady-state response plots in Problem P3.81^6].5π .6885. theta = [0 pi/2].’markersize’.a.’filled’).1.44.’FontSize’. cos_term = cos(term1+term2).LFS). [H] = freqresp(b. ylabel(’y(n)’..length(n)). Matlab script: % P0318b: y(n) = sum_{m=0}^{3} x(n-2m)-sum_{l=1}^{3} (0. ytick = [0:0. A = [1 1].3]).’markersize’.TFS).’off’. set(Hs.5 y(n) 2 1. ytick = [0:0.a.ytick).6. set(0. y2 = filter(b.y1. pha = phaH+theta.5 1 0.6885 and H e j 0.5 1 0. y1 = mag*cos_term.’FontSize’.5π  = P3 P3 m=0 e− j πℓ ℓ=0 (0. Hf_1 = figure.5πn+π/2) 2.LFS).5].’FontSize’. The steady-state responses are shown in Figure 3. set(Hs.’YTick’. title([’Output response y(n) using the filter function’].’NumberTitle’. x(n) = 1 + cos (0. 5πm = 0 and H e j 0.18c . Matlab script:  = P3 P3 m=0 e− j 1. w = [pi/4 3*pi/4]. set(0.45: Steady-state response plots in Problem P3.’filled’). Hs = stem(n.Solutions Manual for DSP using Matlab (2nd Edition) 120 2006 3.3]).’defaultfigurepaperposition’..81) 2ℓ e− j 0.y2.’P0318c’).2). close all. term1 = w’*n. set(Hf_1.’FontSize’.a. SS response yss(n): x(n) = 2sin(πn/4)+3cos(3 π n/4) y(n) 4 2 0 −2 0 5 10 15 20 25 30 35 40 45 50 45 50 n Output response y(n) using the filter function y(n) 4 2 0 −2 0 5 10 15 20 25 30 35 40 n Figure 3. set(Hs. title([’SS response y_{ss}(n): x(n) = 2sin({\pi}n/4)+3cos(3 \pi n/4)’]. Hs = stem(n.’markersize’. [H] = freqresp(b.’FontSize’.y1. subplot(2.. a = [1 0 0. phaH = angle(H)./EPSFILES/P0318c.5πℓ =0 % P0318c: y(n) = sum_{m=0}^{3} x(n-2m)-sum_{l=1}^{3} (0.. x(n) = 2 sin (π n/4) + 3 cos (3π n/4): We need responses at ω = π/4 and ω = 3π/4.1. ylabel(’y(n)’.1). A = [2 3]. axis([-1 51 -3 4]).’FontSize’. ’FontSize’. axis([-1 51 -3 4]).’off’.*magH. magH = abs(H).. term2 = pha’*ones(1.’markersize’. xlabel(’n’.TFS). y1 = mag*cos_term.’Name’.w).’filled’).81^6].81) 2ℓ e− j 1. xlabel(’n’.x). n = [0:50]. y2 = filter(b. mag = A.[0..2). pha = phaH+theta.75π Hence the steady-state response is y(n) = 0.81^4 0 0.45.6. title([’Output response y(n) using the filter function’].LFS). x = 2*sin(pi*n/4)+3*cos(3*pi*n/4). set(Hs. H e j 0.LFS).LFS). ylabel(’y(n)’.LFS). clc.81^2 0 0. Hf_1 = figure.length(n)). b = [1 0 1 0 1 0 1]. The steady-state responses are shown in Figure 3..2). theta = [-pi/2 0].81)^l y(n-2l) % x(n) = 2 * sin(\pi n/4)+3 * cos(3 \pi n/4). print -deps2 . cos_term = cos(term1+term2).1.5πℓ ℓ=0 (0.25π  = P3 P3 m=0 e− j 0. ’FontSize’.’NumberTitle’.a.5πm ℓ=0 (0.’FontSize’. subplot(2.TFS).0.. ytick = [-20:5:30]. 3.. ylabel(’y(n)’. x = A*cos(term1).length(k)). set(Hf_1. 4. term1 = w’*n..’FontSize’./EPSFILES/P0318d. y1 = mag*cos_term.’markersize’.TFS).2).25π = 0 Hence the steady-state response is y(n) = 1.’filled’). theta = zeros(1.*magH.’markersize’.46: Steady-state response plots in Problem P3.a.LFS). 2. y2 = filter(b.81^6].’FontSize’.length(n)).’FontSize’.2). title([’Output response y(n) using the filter function’].LFS). 5. a = [1 0 0. Hf_1 = figure. The steady-state responses are shown in Figure 3.. close all... n = [0:50].81^2 0 0. ytick = [-20:5:30]. set(gca.y1.6885 + 8. axis([-1 51 -10 15]).81^4 0 0. title([’SS response y_{ss}(n): x(n) = sum_{0}^{5} (k+1)cos({\pi}kn/4)’]. H e j0  = P3 P3 m=0 e− j 0 (0. k = [0:5].y2. Matlab script: % P0318d: y(n) = sum_{m=0}^{3} x(n-2m)-sum_{l=1}^{3} (0. set(0. b = [1 0 1 0 1 0 1].x).1. subplot(2. Hs = stem(n.’off’.3]).’filled’).w).[0.18d .TFS). y(n) SS response yss(n): x(n) = sum50 (k+1)cos(πkn/4) 15 10 5 0 −5 −10 0 5 10 15 20 25 30 35 40 45 50 45 50 n y(n) Output response y(n) using the filter function 15 10 5 0 −5 −10 0 5 10 15 20 25 30 35 40 n Figure 3.LFS). ylabel(’y(n)’.ytick).81)^l y(n-2l) % x(n) = sum_{k = 0}^{5} (k+1) cos(pi*k*n/4).a.25π = H e j 0.1. w = pi /4*k. print -deps2 .LFS).4425 cos(nπ ). ’FontSize’.’defaultfigurepaperposition’.46.0. xlabel(’n’. axis([-1 51 -10 15]). magH = abs(H).ytick). pha = phaH+theta.’FontSize’.2006 Solutions Manual for DSP using Matlab (2nd Edition) 4.6885 = H e j π and ℓ=0     H e j 0. cos_term = . set(gca.5π = H e j 0.6. clc. 1.’FontSize’.75π = H e j 1.’NumberTitle’. xlabel(’n’. x(n) = P5 k=0 121 (k + 1) cos (π kn/4): We need responses at ω = kπ/4. Hs = stem(n.’YTick’.’P0318d’). set(Hs. cos(term1+term2). A = (k+1).81)2ℓ e− j 0  = 1.1). set(Hs. term2 = pha’*ones(1.2). mag = A. [H] = freqresp(b.’YTick’.. k = 0. subplot(2.’Name’. phaH = angle(H). ytick = [-2:0.’FontSize’.y2.x).’FontSize’.5 1 0.LFS). theta = [0]. subplot(2. H e jπ  = P3 P3 m=0 e− j 2πm ℓ=0 (0.5 0 −0.2). magH = abs(H).’YTick’.LFS).81)^l y(n-2l) % x(n) = cos(pi*n). mag = A.’filled’). axis([-1 51 -2 2]).LFS).81) 2ℓ e− j 2πm = 1.a.6.81^2 0 0.0.6885 cos (π n). xlabel(’n’.5:2]. set(gca. y2 = filter(b./EPSFILES/P0318e.’P0318e’).TFS). close all.81^4 0 0. axis([-1 51 -2 2]).a. Hs = stem(n. y1 = mag*cos_term. Hf_1 = figure. clc.’NumberTitle’.w). xlabel(’n’. title([’SS response y_{ss}(n) for x(n) = cos(\pi \times n)’]. The steady-state responses are shown in Figure 3. set(gca. title([’Output response y(n) using the filter function’].ytick).6885 Hence the steady-state response is y(n) = 1. Hs = stem(n.length(n)). cos_term = cos(term1+term2).1. subplot(2. ylabel(’y(n)’.’YTick’. set(Hs.ytick).5 1 0.5 0 −0.’markersize’. a = [1 0 0.5 −1 −1.’FontSize’.5 −2 0 5 10 15 20 25 30 35 40 45 50 45 50 n y(n) Output response y(n) using the filter function 2 1.’FontSize’.[0. b = [1 0 1 0 1 0 1]. ylabel(’y(n)’.1). set(0.81^6].*magH. ytick = [-2:0.’FontSize’.Solutions Manual for DSP using Matlab (2nd Edition) 122 2006 5. set(Hs.3]).1. A = [1].’filled’).TFS). n = [0:50]. pha = phaH+theta. y(n) SS response yss(n) for x(n) = cos(π × n) 2 1.’FontSize’.5 −1 −1.2). term2 = pha’*ones(1. Matlab script: % P0318e: y(n) = sum_{m=0}^{3} x(n-2m)-sum_{l=1}^{3} (0.47.5 −2 0 5 10 15 20 25 30 35 40 n Figure 3. [H] = freqresp(b.’markersize’. set(Hf_1.’off’.47: Steady-state response plots in Problem P3.2).y1.5:2]. x = cos(pi*n).’Name’. phaH = angle(H). w = [pi]..’defaultfigurepaperposition’. x(n) = cos (π n): We need response at ω = π . term1 = w’*n.LFS).18e . print -deps2 . clc.5)..LFS). Ts = 0.’YTick’.’XTick’.w).19 An analog signal xa (t) = sin (1000π t) is sampled using the following sampling intervals. magtick = [0:100:300]./EPSFILES/P0319a.LFS).1.. n = [-250:250]. close all.TFS).6 .’LineWidth’. set(Hf_1.magtick).6 −0.’FontSize’. wtick = [-1:0.’NumberTitle’. title(’Phase response x_1(n) = sin(1000 \pi n T_s).’XTick’.wtick).48.8 1 0.2 0.’FontSize’. subplot(2. T_s = 0. w = linspace(-pi.wtick). The spectra are shown in Figure 3. xlabel(’\omega / \pi’.2 0. subplot(2.LFS). Ts = 0.48: Spectrum plots in Problem P3.2 0 ω/π 0.’FontSize’.5).1 ms: Matlab script: % P0319a: x_a(t) = sin(1000*pi*t). Ts = 0.’off’. .’P0319a’).8 −0.1. T_s = 0. phaX = angle(X).LFS). print -deps2 .4 Figure 3. set(gca.1 msec’. ylabel(’|X|’.’LineWidth’.’FontSize’.phaX*180/pi.1.0001. % Ts = 0.1.. X = dtft(x.8 1 Degrees Phase response x1(n) = sin(1000 π n Ts).’FontSize’. title(’Magnitude response x_1(n) = sin(1000 \pi n T_s).TFS). set(gca.6 −0.1 ms.1 msec’. 1.19a 0.4 0.magtick).magX.’FontSize’.1 msec 180 120 60 0 −60 −120 −180 −1 −0.2:1]. x = sin(1000*pi*n*Ts). axis([-1 1 -180 180]). plot(w/pi.pi.2 0 ω/π 0.2:1]. plot(w/pi.4 −0. . magtick = [-180:60:180]. set(gca. wtick = [-1:0.2).501).’Name’. magX = abs(X). % Hf_1 = figure. Magnitude response x1(n) = sin(1000 π n Ts).1).n. axis([-1 1 0 300]). set(gca. T_s = 0. ylabel(’Degrees’.2006 Solutions Manual for DSP using Matlab (2nd Edition) 123 P3.4 −0.. xlabel(’\omega / \pi’.8 −0.1 msec |X| 300 200 100 0 −1 −0.’YTick’..6 0. X = dtft(x.49: Spectrum plots in Problem P3. T_s = 1 msec’.’Name’.LFS).1.2:1]. . subplot(2.8 −0.wtick).n. set(Hf_1. plot(w/pi.’FontSize’.2).8 −0.4 Figure 3.TFS). .4 0. Magnitude response x1(n) = sin(1000 π n Ts).8 1 Degrees Phase response x1(n) = sin(1000 π n Ts). title(’Phase response x_1(n) = sin(1000 \pi n T_s). Ts = 1 ms: Matlab script: % P0319b: x_a(t) = sin(1000*pi*t).’LineWidth’. set(gca. subplot(2.w). magX = abs(X).2 0. axis([-1 1 -180 180]).LFS). title(’Magnitude response x_1(n) = sin(1000 \pi n T_s).. T_s = 1 ms. xlabel(’\omega / \pi’..’FontSize’.1.’P0319b’). ylabel(’|X|’.6 .19b 0.001. set(gca. The spectra are shown in Figure 3.’FontSize’.’off’. set(gca.2 0. xlabel(’\omega / \pi’.1. close all. ylabel(’Degrees’. Ts = 1 msec 180 120 60 0 −60 −120 −180 −1 −0. T_s = 1 msec’. phaX = angle(X).’FontSize’..’XTick’.’FontSize’.wtick).6 0. x = sin(1000*pi*n*Ts).Solutions Manual for DSP using Matlab (2nd Edition) 124 2006 2. wtick = [-1:0. magtick = [-180:60:180]./EPSFILES/P0319b.6 −0. Ts = 1 msec |X| 1 0 −1 −1 −0.8 1 0.1). w = [-500:500]*pi/500.LFS). % Hf_1 = figure.4 −0.2 0 ω/π 0. n = [-25:25].magtick).TFS).’NumberTitle’.2:1]. clc.4 −0.’XTick’.’FontSize’. wtick = [-1:0. axis([-1 1 -1 1]).. print -deps2 .1.5). % Ts = 0.magX.5). plot(w/pi.’LineWidth’.6 −0.LFS).’YTick’.2 0 ω/π 0.phaX*180/pi.49.. LFS).01.2 0. % Hf_1 = figure. axis([-1 1 -1 1]).2). subplot(2./EPSFILES/P0319c.’LineWidth’. n = [-25:25].TFS). plot(w/pi.1).’NumberTitle’.4 Figure 3.8 −0.TFS). print -deps2 .01 sec’.T_s = 0.2:1]. The spectra are shown in Figure 3.’Name’.2006 Solutions Manual for DSP using Matlab (2nd Edition) 125 3. wtick = [-1:0. set(Hf_1.’P0319c’).’LineWidth’...LFS). Magnitude response x1(n) = sin(1000 π n Ts). plot(w/pi. ylabel(’|X|’.phaX*180/pi.w). ylabel(’Degrees’.01 sec: Matlab script: % P0319c: x_a(t) = sin(1000*pi*t). magX = abs(X). wtick = [-1:0.5)..8 1 0.01 sec. x = sin(1000*pi*n*Ts). set(gca.magtick). X = dtft(x. axis([-1 1 -180 180]).’FontSize’.8 1 Degrees Phase response x1(n) = sin(1000 π n Ts).1.6 −0.’off’.8 −0. .01 sec |X| 1 0 −1 −1 −0.. . close all. title(’Phase response x_1(n) = sin(1000 \pi n T_s).’FontSize’.’YTick’. xlabel(’\omega / \pi’.’FontSize’.6 . T_s = 0.50.. xlabel(’\omega / \pi’.2 0.4 0.6 −0. set(gca.1.19c 0.’FontSize’. Ts = 0.2 0 ω/π 0.4 −0.1.’XTick’.2:1].wtick).50: Spectrum plots in Problem P3.’XTick’. set(gca.4 −0.1.magX.’FontSize’. w = [-500:500]*pi/500.wtick).’FontSize’.LFS).T_s = 0.01 sec’.LFS). magtick = [-180:60:180].Ts = 0. phaX = angle(X). % Ts = 0. title(’Magnitude response x_1(n) = sin(1000 \pi n T_s). clc.n.01 sec 180 120 60 0 −60 −120 −180 −1 −0.Ts = 0.6 0.2 0 ω/π 0. subplot(2.5). Solutions Manual for DSP using Matlab (2nd Edition) 126 2006 P3.20 Sampling frequency Fs = 8000 sam/sec (or sampling interval Ts = 0.125 msec/sam) and impulse response h(n) = (−0.9)n u(n). (a) xa (t) = 10 cos(10000π t). Hence x(n) = xa (nTs ) = 10 cos (10000π n0.000125) = 10 cos(1.25π n). Therefore, the digital frequency is (1.25 − 2)π = −0.75π rad/sam. (b) The steady-state response when x (n) = 10 cos (−0.75π n) = 10 cos(0.75π n: The frequency response is    1 . H e j ω = F [h(n)] = F (−0.9)n u(n) = 1 + 0.9e j ω At ω = −0.75π , the response is Hence  H e j 0.75π =  1 c = 0.7329 ∠1.0517 . 1 + 0.9e j 0.75π yss (n) = 10 (0.7329) cos (0.75π n + 1.0517) which after D/A conversion gives yss (t) as yss,a (t) = 7.329 cos (6000π t1.0517) .  (c) The steady-state DC gain is obtained by setting ω = 0 which is equal to H e j 0 = 1/(1+0.9) = 0.5263. Hence yss (n) = 10 (0.5263) = yss,a (t) = 5.263. (d) Aliased frequencies of F0 for the given sampling rate Fs are F0 + k Fs . Now for F0 = 5 KHz and Fs = 8 KHz, the aliased frequencies are 5 + 8k = {13, 21, . . .} KHz. Therefore, two other xa (t)’s are 10 cos(26000π t) and 10 cos(42000π t). (e) The prefilter should be a lowpass filter with the cutoff frequency of 4 KHz. P3.21 Consider an analog signal xa (t) = cos(20π t), 0 ≤ t ≤ 1. It is sampled at Ts = 0.01, 0.05, and 0.1 sec intervals to obtain x(n). 1. Plots of x (n) for each Ts . Matlab script: % P0321a: plot x(n) for T_s = 0.01 sec,0.05 sec,0.1 sec % x_a(t) = cos(20*pi*t); clc; close all; set(0,’defaultfigurepaperposition’,[0,0,6,4]); Hf_1 = figure; set(Hf_1,’NumberTitle’,’off’,’Name’,’P0321a’); T_s1 = 0.01; n1 = [0:100]; x1 = cos(20*pi*n1*T_s1); subplot(3,1,1); Hs = stem(n1,x1,’filled’); axis([-5 105 -1.2 1.2]); set(Hs,’markersize’,2); xlabel(’n’,’FontSize’,LFS); title([’x(n) = cos(20{\pi}nT_s) for T_s = 0.01 sec’],’FontSize’,TFS); ylabel(’x(n)’,’FontSize’,LFS); T_s2 = 0.05; n2 = [0:20]; x2 = cos(20*pi*n2*T_s2); subplot(3,1,2); Hs = stem(n2,x2,’filled’); set(Hs,’markersize’,2); set(gca,’XTick’,[0:20]); axis([-2 22 -1.2 1.2]); xlabel(’n’,’FontSize’,LFS); ylabel(’x(n)’,’FontSize’,LFS); title([’x(n) = cos(20{\pi}nT_s) for T_s = 0.05 sec’],’FontSize’,TFS); T_s3 = 0.1; n3 = [0:10]; x3 = cos(20*pi*n3*T_s3); 2006 Solutions Manual for DSP using Matlab (2nd Edition) 127 subplot(3,1,3); Hs = stem(n3,x3,’filled’); set(Hs,’markersize’,2); set(gca,’XTick’,[0:10]); axis([-1 11 -1.2 1.2]); xlabel(’n’,’FontSize’,LFS); ylabel(’x(n)’,’FontSize’,LFS); title([’x(n) = cos(20{\pi}nT_s) for T_s = 0.1 sec’],’FontSize’,TFS); print -deps2 ../EPSFILES/P0321a; The plots are shown in Figure 3.51. x(n) = cos(20πnTs) for Ts = 0.01 sec x(n) 1 0 −1 0 10 20 30 40 50 60 70 80 90 100 n x(n) = cos(20πnTs) for Ts = 0.05 sec x(n) 1 0 −1 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 n x(n) = cos(20πnTs) for Ts = 0.1 sec x(n) 1 0 −1 0 1 2 3 4 5 6 7 8 9 10 n Figure 3.51: Plots of x (n) for various Ts in Problem P3.21a. 2. Reconstruction from x(n) using the sinc interpolation. Matlab script: % P0321a: plot x(n) for T_s = 0.01 sec,0.05 sec,0.1 sec % x_a(t) = cos(20*pi*t); clc; close all; set(0,’defaultfigurepaperposition’,[0,0,6,4]); Hf_1 = figure; set(Hf_1,’NumberTitle’,’off’,’Name’,’P0321a’); T_s1 = 0.01; n1 = [0:100]; x1 = cos(20*pi*n1*T_s1); subplot(3,1,1); Hs = stem(n1,x1,’filled’); axis([-5 105 -1.2 1.2]); set(Hs,’markersize’,2); xlabel(’n’,’FontSize’,LFS); title([’x(n) = cos(20{\pi}nT_s) for T_s = 0.01 sec’],’FontSize’,TFS); ylabel(’x(n)’,’FontSize’,LFS); T_s2 = 0.05; n2 = [0:20]; x2 = cos(20*pi*n2*T_s2); subplot(3,1,2); Hs = stem(n2,x2,’filled’); set(Hs,’markersize’,2); set(gca,’XTick’,[0:20]); axis([-2 22 -1.2 1.2]); xlabel(’n’,’FontSize’,LFS); ylabel(’x(n)’,’FontSize’,LFS); title([’x(n) = cos(20{\pi}nT_s) for T_s = 0.05 sec’],’FontSize’,TFS); T_s3 = 0.1; n3 = [0:10]; x3 = cos(20*pi*n3*T_s3); subplot(3,1,3); Hs = stem(n3,x3,’filled’); set(Hs,’markersize’,2); Solutions Manual for DSP using Matlab (2nd Edition) 128 2006 set(gca,’XTick’,[0:10]); axis([-1 11 -1.2 1.2]); xlabel(’n’,’FontSize’,LFS); ylabel(’x(n)’,’FontSize’,LFS); title([’x(n) = cos(20{\pi}nT_s) for T_s = 0.1 sec’],’FontSize’,TFS); print -deps2 ../EPSFILES/P0321a; The reconstruction is shown in Figure 3.52. Sinc Interpolation: Ts = 0.01 sec ya(t) 1 0 −1 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1 0.8 0.9 1 0.8 0.9 1 t in sec Sinc Interpolation: T = 0.05 sec s ya(t) 1 0 −1 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 t in sec Sinc Interpolation: Ts = 0.1 sec ya(t) 1 0 −1 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 t in sec Figure 3.52: The sinc interpolation in Problem P3.21b. 3. Reconstruction from x(n) using the spline interpolation. Matlab script: % P0321c Spline Interpolation: x_a(t) = cos(20*pi*t); 0 <= t <= 1; % T_s = 0.01 sec,0.05 sec and 0.1 sec; clc; close all; set(0,’defaultfigurepaperposition’,[0,0,6,4]); Hf_1 = figure; set(Hf_1,’NumberTitle’,’off’,’Name’,’P0321c’); % Ts1 = 0.01; Fs1 = 1/Ts1; n1 = [0:100]; nTs1 = n1*Ts1; x1 = cos(20*pi*nTs1); Dt = 0.001; t = 0:Dt:1; xa1 = spline(nTs1,x1,t); subplot(3,1,1); plot(t,xa1,’LineWidth’,1.5); axis([0 1 -1.2 1.2]); xlabel(’t in sec’,’FontSize’,LFS); ylabel(’y_a(t)’,’FontSize’,LFS); title([’Spline Interpolation: T_s = 0.01 sec’],’FontSize’,TFS); % Ts2 = 0.05; Fs2 = 1/Ts2; n2 = [0:20]; nTs2 = n2*Ts2; x2 = cos(20*pi*nTs2); Dt = 0.001; t = 0:Dt:1; xa2 = spline(nTs2,x2,t); subplot(3,1,2); plot(t,xa2,’LineWidth’,1.5); axis([0 1 -1.2 1.2]); xlabel(’t in sec’,’FontSize’,LFS); ylabel(’y_a(t)’,’FontSize’,LFS); title([’Spline Interpolation: T_s = 0.05 sec’],’FontSize’,TFS); grid; % 2006 Solutions Manual for DSP using Matlab (2nd Edition) 129 Ts3 = 0.1; Fs3 = 1/Ts3; n3 = [0:10]; nTs3 = n3*Ts3; x3 = cos(20*pi*nTs3); Dt = 0.001; t = 0:Dt:1; xa3 = spline(nTs3,x3,t); subplot(3,1,3); plot(t,xa3,’LineWidth’,1.5); axis([0 1 -1.2 1.2]); xlabel(’t in sec’,’FontSize’,LFS); ylabel(’y_a(t)’,’FontSize’,LFS); title([’Spline Interpolation: T_s = 0.1 sec’],’FontSize’,TFS); grid; print -deps2 ../EPSFILES/P0321c; The reconstruction is shown in Figure 3.53. Spline Interpolation: Ts = 0.01 sec ya(t) 1 0 −1 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1 0.8 0.9 1 0.8 0.9 1 t in sec Spline Interpolation: Ts = 0.05 sec ya(t) 1 0 −1 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 t in sec Spline Interpolation: Ts = 0.1 sec ya(t) 1 0 −1 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 t in sec Figure 3.53: The sinc interpolation in Problem P3.21c. 4. Comments: From the plots in Figures it is clear that reconstructions from samples at Ts = 0.01 and 0.05 depict the original frequency (excluding end effects) but reconstructions for Ts = 0.1 show the original frequency aliased to zero. Furthermore, the cubic spline interpolation is a better reconstruction than the sinc interpolation, that is, the sinc interpolation is more susceptible to boundary effect. P3.22 Consider the analog signal xa (t) = cos(20π t + θ), 0 ≤ t ≤ 1. It is sampled at Ts = 0.05 sec intervals to obtain x(n). Let θ = 0, π/6, π/4, π/3, π/2. For each of these θ values, perform the following. (a) Plots of xa (t) and x(n) for θ = 0, π/6, π/4, π/3, π/2. Matlab script: % P0322a: x_a(t) = cos(20*pi*t+theta); x(n) for theta = 0,pi/6,pi/4,pi/3, pi/2 clc; close all; set(0,’defaultfigurepaperposition’,[0,0,6,7]); Hf_1 = figure; set(Hf_1,’NumberTitle’,’off’,’Name’,’P0322a’); Ts = 0.05; Fs = 1/Ts; Dt = 0.001; t = 0:Dt:1; n = [0:20]; nTs = n*Ts; theta1 = 0; x_a1 = cos(20*pi*t+theta1); x1 = cos(20*pi*nTs+theta1); subplot(5,1,1); plot(t,x_a1,’LineWidth’,1.5); axis([0 1 -1.2 1.2]); hold on; plot(nTs,x1,’o’); xlabel(’t in sec’,’FontSize’,LFS); title(’x_a(t) and x(n) for \theta = 0’,’FontSize’,TFS); 130 Solutions Manual for DSP using Matlab (2nd Edition) ylabel(’Amplitude’,’FontSize’,LFS); theta2 = pi/6; x_a2 = cos(20*pi*t+theta2); x2 = cos(20*pi*nTs+theta2); subplot(5,1,2); plot(t,x_a2,’LineWidth’,1.5); axis([0 1 -1.2 1.2]); hold plot(nTs,x2,’o’); xlabel(’t in sec’,’FontSize’,LFS); title(’x_a(t) and x(n) for \theta = \pi/6’,’FontSize’,TFS); ylabel(’Amplitude’,’FontSize’,LFS); theta3 = pi/4; x_a3 = cos(20*pi*t+theta3); x3 = cos(20*pi*nTs+theta3); subplot(5,1,3); plot(t,x_a3,’LineWidth’,1.5); axis([0 1 -1.2 1.2]); hold plot(nTs,x3,’o’); xlabel(’t in sec’,’FontSize’,LFS); title(’x_a(t) and x(n) for \theta = \pi/4’,’FontSize’,TFS); ylabel(’Amplitude’,’FontSize’,LFS); theta4 = pi/3; x_a4 = cos(20*pi*t+theta4); x4 = cos(20*pi*nTs+theta4); subplot(5,1,4); plot(t,x_a4,’LineWidth’,1.5); axis([0 1 -1.2 1.2]); hold plot(nTs,x4,’o’); xlabel(’t in sec’,’FontSize’,LFS); title(’x_a(t) and x(n) for \theta = \pi/3’,’FontSize’,TFS); ylabel(’Amplitude’,’FontSize’,LFS); theta5 = pi/2; x_a5 = cos(20*pi*t+theta5); x5 = cos(20*pi*nTs+theta5); subplot(5,1,5); plot(t,x_a5,’LineWidth’,1.5); axis([0 1 -1.2 1.2]); hold plot(nTs,x5,’o’); xlabel(’t in sec’,’FontSize’,LFS); title(’x_a(t) and x(n) for \theta = \pi/2’,’FontSize’,TFS); ylabel(’Amplitude’,’FontSize’,LFS); print -deps2 ../EPSFILES/P0322a; 2006 on; on; on; on; The reconstruction is shown in Figure 3.54. (b) Reconstruction of the analog signal ya (t) from the samples x(n) using the sinc interpolation (for θ = 0, π/6, π/4, π/3, π/2. Matlab script: % P0322b: Sinc Interpolation for theta = 0,pi/6,pi/4,pi/3, pi/2 clc; close all; set(0,’defaultfigurepaperposition’,[0,0,6,7]); Hf_1 = figure; set(Hf_1,’NumberTitle’,’off’,’Name’,’P0322b’); Ts = 0.05; Fs = 1/Ts; Dt = 0.001; t = 0:Dt:1; n = [0:20]; nTs = n*Ts; theta1 = 0; x1 = cos(20*pi*nTs+theta1); y_a1 = x1*sinc(Fs*(ones(length(n),1)*t-nTs’*ones(1,length(t)))); subplot(5,1,1); plot(t,y_a1,’LineWidth’,1.5); hold on; plot(nTs,x1,’o’); axis([0 1 -1.2 1.2]); xlabel(’t in sec’,’FontSize’,LFS); title(’Sinc Interpolation for \theta = 0’,’FontSize’,TFS); ylabel(’Amplitude’,’FontSize’,LFS); theta2 = pi/6; x2 = cos(20*pi*nTs+theta2); y_a2 = x2*sinc(Fs*(ones(length(n),1)*t-nTs’*ones(1,length(t)))); subplot(5,1,2); plot(t,y_a2,’LineWidth’,1.5); hold on; axis([0 1 -1.2 1.2]) plot(nTs,x2,’o’); xlabel(’t in sec’,’FontSize’,LFS); title(’Sinc Interpolation for \theta = \pi/6’,’FontSize’,TFS); ylabel(’Amplitude’,’FontSize’,LFS); theta3 = pi/4; x3 = cos(20*pi*nTs+theta3); y_a3 = x3*sinc(Fs*(ones(length(n),1)*t-nTs’*ones(1,length(t)))); subplot(5,1,3); plot(t,y_a3,’LineWidth’,1.5); hold on; axis([0 1 -1.2 1.2]) plot(nTs,x3,’o’); xlabel(’t in sec’,’FontSize’,LFS); title(’Sinc Interpolation for \theta = \pi/4’,’FontSize’,TFS); ylabel(’Amplitude’,’FontSize’,LFS); theta4 = pi/3; x4 = cos(20*pi*nTs+theta4); 2006 Solutions Manual for DSP using Matlab (2nd Edition) 131 Amplitude xa(t) and x(n) for θ = 0 1 0 −1 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1 0.7 0.8 0.9 1 0.7 0.8 0.9 1 0.7 0.8 0.9 1 0.7 0.8 0.9 1 t in sec x (t) and x(n) for θ = π/6 Amplitude a 1 0 −1 0 0.1 0.2 0.3 0.4 0.5 0.6 t in sec x (t) and x(n) for θ = π/4 Amplitude a 1 0 −1 0 0.1 0.2 0.3 0.4 0.5 0.6 t in sec Amplitude xa(t) and x(n) for θ = π/3 1 0 −1 0 0.1 0.2 0.3 0.4 0.5 0.6 t in sec Amplitude xa(t) and x(n) for θ = π/2 1 0 −1 0 0.1 0.2 0.3 0.4 0.5 0.6 t in sec Figure 3.54: The sinc interpolation in Problem P3.22a. y_a4 = x4*sinc(Fs*(ones(length(n),1)*t-nTs’*ones(1,length(t)))); subplot(5,1,4); plot(t,y_a4,’LineWidth’,1.5); axis([0 1 -1.2 1.2]); hold on; plot(nTs,x4,’o’); xlabel(’t in sec’,’FontSize’,LFS); title(’Sinc Interpolation for \theta = \pi/3’,’FontSize’,TFS); ylabel(’Amplitude’,’FontSize’,LFS); theta5 = pi/2; x5 = cos(20*pi*nTs+theta5); y_a5 = x5*sinc(Fs*(ones(length(n),1)*t-nTs’*ones(1,length(t)))); subplot(5,1,5); plot(t,y_a5,’LineWidth’,1.5); axis([0 1 -1.2 1.2]); hold on; plot(nTs,x5,’o’); xlabel(’t in sec’,’FontSize’,LFS); title(’Sinc Interpolation for \theta = \pi/3’,’FontSize’,TFS); ylabel(’Amplitude’,’FontSize’,LFS); print -deps2 ../EPSFILES/P0322b; Solutions Manual for DSP using Matlab (2nd Edition) 132 2006 The reconstruction is shown in Figure 3.55. Amplitude Sinc Interpolation for θ = 0 1 0 −1 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1 0.8 0.9 1 0.8 0.9 1 0.8 0.9 1 0.8 0.9 1 t in sec Amplitude Sinc Interpolation for θ = π/6 1 0 −1 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 t in sec Amplitude Sinc Interpolation for θ = π/4 1 0 −1 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 t in sec Amplitude Sinc Interpolation for θ = π/3 1 0 −1 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 t in sec Amplitude Sinc Interpolation for θ = π/3 1 0 −1 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 t in sec Figure 3.55: The sinc interpolation in Problem P3.22b. (c) Reconstruction of the analog signal ya (t) from the samples x(n) using the spline interpolation (for θ = 0, π/6, π/4, π/3, π/2. Matlab script: % P0322c: Spline Interpolation for theta = 0,pi/6,pi/4,pi/3, pi/2 clc; close all; set(0,’defaultfigurepaperposition’,[0,0,6,7]); Hf_1 = figure; set(Hf_1,’NumberTitle’,’off’,’Name’,’P0322c’); Ts = 0.05; Fs = 1/Ts; Dt = 0.001; t = 0:Dt:1; n = [0:20]; nTs = n*Ts; theta1 = 0; x1 = cos(20*pi*nTs+theta1); y_a1 = spline(nTs,x1,t); subplot(5,1,1); plot(t,y_a1,’LineWidth’,1.5); axis([0 1 -1.2 1.2]); hold on; plot(nTs,x1,’o’); xlabel(’t in sec’,’FontSize’,LFS); title(’Spline Interpolation for theta = 0’,’FontSize’,TFS); theta4 = pi/3.5 0.3 0.’FontSize’.9 1 0.6 0. plot(nTs.8 0. title(’Spline Interpolation for theta = \pi/3’.4 0.2). axis([0 1 -1.9 1 0.1.56: The sinc interpolation in Problem P3. ylabel(’Amplitude’.5 0.4 0.5 0. axis([0 1 -1.5). plot(t.3 0.t).5 0.’LineWidth’.7 t in sec Figure 3. theta2 = pi/6.6 0.9 1 0. x4 = cos(20*pi*nTs+theta4).2 1. hold on.2 0.7 t in sec Amplitude Spline Interpolation for theta = π/2 1 0 −1 0 0. theta3 = pi/4.y_a2.x3.7 t in sec Amplitude Spline Interpolation for theta = π/3 1 0 −1 0 0.3).8 0.6 0.9 1 0.’FontSize’. xlabel(’t in sec’.1 0. subplot(5.’o’).8 0. x2 = cos(20*pi*nTs+theta2).TFS).’LineWidth’.2 0.LFS).1. plot(t.1.9 1 t in sec Amplitude Spline Interpolation for theta = π/6 1 0 −1 0 0.t). subplot(5. ylabel(’Amplitude’.TFS). x3 = cos(20*pi*nTs+theta3).t).LFS). y_a2 = spline(nTs.1. title(’Spline Interpolation for theta = \pi/6’.1 0.’FontSize’.2006 Solutions Manual for DSP using Matlab (2nd Edition) 133 Amplitude Spline Interpolation for theta = 0 1 0 −1 0 0. ylabel(’Amplitude’.1 0.y_a3.6 0.’FontSize’.2]). y_a4 = spline(nTs.3 0. hold on.4 0.x2.8 0.22c.3 0.2 0.1 0.x3. y_a3 = spline(nTs.1 0.x2.4 0.’FontSize’.2 1.5).8 0.5 0.6 0.LFS).’o’). plot(nTs.LFS).x4. xlabel(’t in sec’.7 0.4 0.LFS).’FontSize’.2 0.3 0.2]).’FontSize’.2 0. .7 t in sec Amplitude Spline Interpolation for theta = π 1 0 −1 0 0. y_a5.’LineWidth’.t).LFS).4). hold on. ylabel(’Amplitude’.2 1.5). axis([0 1 -1. The reconstruction is shown in Figure 3. title(’Spline Interpolation for theta = \pi’.5).TFS).’o’).LFS).x5.’FontSize’.x5. (d) When a sinusoidal signal is sampled at f = 2 samples per cycle as is the case in this problem. xlabel(’t in sec’.’LineWidth’.134 Solutions Manual for DSP using Matlab (2nd Edition) 2006 subplot(5. xlabel(’t in sec’.’FontSize’. plot(t.x4. Thus the amplitude of the reconstructed signal y(t) is also equal to cos(θ). then the resulting samples x(n) has the amplitude that depends on the phase of the signal.’FontSize’. title(’Spline Interpolation for theta = \pi/2’.1. axis([0 1 -1. plot(nTs.y_a4.’FontSize’..LFS).56. subplot(5./EPSFILES/P0322c. ylabel(’Amplitude’.1.5). plot(nTs.’FontSize’.’o’).2 1.’FontSize’. hold on. . x5 = cos(20*pi*nTs+theta5). plot(t. In particular note that this amplitude is given by cos(θ).1. theta5 = pi/2. print -deps2 . y_a5 = spline(nTs.TFS).1.LFS).2]).2]). xb1 = filter(b.0.delta).n] = impseq(0. [u. −3}: Then X (z) = 3z 2 + 2z + 1 − 2z −1 + 3z −2 . 2.8].3z −1 − 0.^n).10).0. b1 = [0 2 3]. [delta.n] = stepseq(2.8).a2. |z| > 0. n1 = -fliplr(n). −2. a = [1 -0.8} −1 1 − 0.n1.a.Chapter 4 The z-Transform P4. xb1 = fliplr(xb1). a1 = [1].8 1 + 0.m clc. |z| > 0.n] = impseq(0.1 The z-transform computation using definition (4.5)n + (−0.0. x(n) = [(0.4z −2 Matlab verification: 135 1 1 + .8)n u(n) = = 2 + 0. error = max(abs(xa1-xa2)) error = 0 2.8)n ]u(n): Then     X (z) = Z (0.10). n2 = n.8z −1 Matlab verification: % P0401b. xa2 = [0 0 3 2 1 -2 -3 0 0].n2).delta).8)n z −n = (0. ↑ Matlab verification: % P0401a. b2 = [1 -2 -3].3z −1 .8 1 − 0.na1] = sigadd(xb1. xb2 = filter(b2.xb2.8)2 z −2 ∞ X n=0 (0.delta). [xa1. x(n) = (0. close all.8)n z −n = 0.5z 1 + 0. 1. error = max(abs(xb1-xb2)) error = 1. 0 < |z| < ∞.64z −2 .4). close all.5} ∩ {|z| > 0. b = [0 0 0.5)n u(n) + Z (−0.64].8)n u(n − 2): Then X (z) = ∞ X n=2 (0.m clc. 1.a1.1102e-016 3. x(n) = {3. xb2 = ((0. a2 = [1]. xb1 = filter(b1. {|z| > 0.8z −1 . [delta.*u.1). |z| > 3 1 − 6z −1 + 9z −2 1 − 3z −1 1 − 9z −1 + 27z −2 − 27z −3 Matlab verification: % P0401e. xb1 = filter(b.*u)+(((-0.n1] = impseq(0. |z| > 3 −1 dz 1 − 3z 1 − 3z −1 3z −1 1 1 − 3z −1 = + = .4π e z 2 1 2 = 0 X 1 − j 0.4π n)z 2−1 e j 0.n2] = stepseq(-7.4π )]z 1 − [0.7).8). [u. b = [1 -3].4πn  zn = 1 2 1 2 = 1 − [0.a.^n2).3].delta). [u. |z| < 2 1 − 2[0.0).5 cos(0.-7. x(n) = 2n cos(0.*u.4π z n=0 1 1− n n=−∞ ∞ X = 1 j 0.25].7).m clc.4π n)u(−n): Consider X (z) = = Hence ∞ X n 2 cos(0.4π n)z n 2−1 e− j 0. close all. [delta.4πn 1 +e 2 ! −n − j 0.4π )]z = .m clc. b = 0. xb1 = fliplr(xb1).4*pi*n2)).delta).4π )]z . x(n) = (n + 1)(3)n u(n): Consider x(n) = (n + 1)(3)n u(n) = n3n u(n) + 3n u(n) Hence    n  d 1 1 X (z) = Z n3 u(n) + Z 3 u(n) = −z + .^n).4π n)u(−n)z n=−∞ ∞ X −n  2 n=0 e j 0.*u).4π )]z + 0.4].Solutions Manual for DSP using Matlab (2nd Edition) 136 2006 % P0401c.7).5 cos(0.4π )]z + 0. a = [1 -cos(0.25z 2 1 − [cos(0. error = max(abs(xb1-xb2)) error = 1.5 cos(0.25z 2 Matlab verification: % P0401d.7).0.4*pi) 0.25z 2 1− X (z) = + 2 cos(0.4π )]z + 0.a. error = max(abs(xb1-xb2)) error = 2. [delta.0.7). xb2 = ((2.*u. close all. a = [1 -9 27 -27].5 cos(0.n] = stepseq(0. |z| < 2 1 − [cos(0.0.4π z n=0 n .^n2)).4π e z 2 ! −n n + = ∞ X n=0 ∞ 1X 2 2−n cos(0.*cos(0.^n). xb1 = filter(b. |z| < 2 1 − [0.delta).3 -0.n1] = impseq(0.0.0. xb1 = filter(b. [u. error = max(abs(xb1-xb2))  n  .4*pi)]. b = [ 2 0.n2] = stepseq(0. xb2 = ((n2+1).5*[2 -cos(0.a.1102e-016 4.m clc. a = [1 0.*(3.n] = impseq(0. close all. [delta.5).7756e-017 5. xb2 = (((0. 2006 Solutions Manual for DSP using Matlab (2nd Edition) error = 0 137 . |z| > 0. Let  x(n/2).9487 1 − 1.^n2). error = max(abs(xb1-xb2)) error = 1. · · · . otherwise.0. |z| > 0.9)2 z −2 1 − 0. xb1 = filter(b. Matlab verification: % P0402c. ±1.6). b = [1 0 -0. y(n) = 0.9*cos(pi/4) 0 0. n = 0. close all.81z −4 3. ±2.Solutions Manual for DSP using Matlab (2nd Edition) 138 P4.m clc. xb2 = zeros(1.81z −2 Hence Y (z) = √ 1 − 0.delta).9). .2728z −2 + 0.0. [u.6364z −1 . 1.9)n cos(π n/4)u(n).n1] = impseq(0. .a. n = 0.9) cos(π/4)]z −1 + (0.9*cos(pi/4)].9)n cos(π n/4)u(n) = = 1 − [(0. ±2.9) cos(π/4)]z −1 1 − 2[(0.n2] = stepseq(0. [delta.2442e-016 2006 .*cos(pi*n2/4)).2*length(x1)). xb2(1:2:end) = x1.2 Consider the sequence x(n) = (0. The z-transform Y (z) of y(n) in terms of the z-transform X (z) of x(n): Consider Y (z) = = ∞ X n=−∞ ∞ X m=−∞ y(n)z −n = ∞ X x(n/2)z −n .9 = 0.81].6364z −2 . . a = [1 0 2*-0.2728z −1 + 0.*u. ±4. x1 = (((0.9 1 − 1. The z-transform of x(n) is given by   X (z) = Z (0.13). n=−∞ ∞ X x(m)z −2m = x(m) z 2 m=−∞ −m = X (z 2 ) 2. error = max(abs(xb1-xb2)) error = 0 Hf_1 = figure.1).3 Computation of z-transform using properties and the z-transform table: 1.1.5 2 0 −0.0.5 −1 −1 −0. [delta.3.delta).1 pole-zero plot .Hl] = zplane(b.5 1 Real Part Figure 4.5 0 -1/16].0.’NumberTitle’. a = [1 0 3/16 0 3/256 0 1/(256*16)].5 0 0. b = [0 -8 0 -1.a. [Hz. close all.xb2 = (((n2-3).’linewidth’.*cos((pi/2)*(n2-1))).’Name’.^(n2-2))).9). set(Hz. x(n) = 2δ(n − 2) + 3u(n − 3): X (z) = 2z −2 + 3z −3 1 2z −2 + z −3 = ..n1] = impseq(0. [u.’off’.Hp.2006 Solutions Manual for DSP using Matlab (2nd Edition) 139 P4.1). set(Hp./epsfiles/P0403e.’P0403e’). |z| > 1 1 − z −1 1 − z −1 Matlab script: clc.’linewidth’.a).9). The pole-zero plot is shown in Figure 4.1: Problem P4.*u.n2] = stepseq(0.’FontSize’. print -deps2 . title(’Pole-Zero plot’. Pole−Zero plot Imaginary Part 1 0. set(Hf_1.TFS).*((1/4). xb1 = filter(b. /epsfiles/P0403b. close all.5 cos(0.3*pi))].1045z −1 = = .5625z −2 Z (z) = 3 Matlab script: clc.0.75 cos(0.3π )]z −1 + (0.Hl] = zplane(b.*u+4*(((0.^n2).5 0 0.Solutions Manual for DSP using Matlab (2nd Edition) 2006 2.4409e-016 Hf_1 = figure.’NumberTitle’.3*pi*n2)).2: Problem P4.’P0403b’).n2] = stepseq(0. xb1 = filter(b. [u.’linewidth’.3*pi)-2.75 cos(0.5 1 Real Part Figure 4.25*cos(0.3π )]z −1 + (0.*cos(0.^n2).75)n sin(0.1). [Hz.. xb2 = 3*(((0.3π ) − 2.75 sin(0.25 cos(0. Pole−Zero plot 1 Imaginary Part 140 0.75).5625]. x(n) = 3(0. set(Hz.8817z −1 + 0.75 cos(0.n1] = impseq(0.5*cos(0.3*pi) 0.0.1).’FontSize’.75 1 − 1. error = max(abs(xb1-xb2)) error = 4.’Name’.*u .*sin(0.3π n)u(n): 1 − [0.3π )]z −1 + 4 1 − 2[0. title(’Pole-Zero plot’.Hp.a). 3π )z −1 + 0. set(Hp.7).3*pi*n2)). b = [3 (3*sin(0.75)2 z −2 1 − 2[0.’off’.75). The pole-zero plot is shown in Figure 4.75)n cos(0.5625z −2 1 − 0. 7).75)2 z −2 −1 3 + [3 sin(0. print -deps2 . 3π )]z 3 + 1. [delta.3π n)u(n) + 4(0.3. |z| > 0.5 0 −0.’linewidth’.a.2.5 −1 −1 −0. a = [1 -1.TFS).3π )]z −1 [0.delta).2 pole-zero plot . set(Hf_1. 9z −1 sin(π/3)z −1 − sin(π/3)z −3 0.8 -0.9).92 (0.5 −2 −1. |z| > 1 1 − 2.9). xb2 = (n2. a = [1 -2.62+sin(pi/3)) .486z −3 + 3.TFS).9z −5 Matlab script: clc.0306z −2 − 2.9)n u(n − 2): Consider 3 x(n) = n sin Hence πn  u(n) + (0. xb1 = filter(b.9). set(Hz.n1] = impseq(0.2094z −4 − 1.81z −2 d .62 0. [u3. set(Hp.81(0.*sin(pi/3*n2)).3 pole-zero plot 141 .9].9)n u(n) dz 3   sin(π/3)z −1 0.1). [u2.9z −1 + 4.2006 Solutions Manual for DSP using Matlab (2nd Edition) 3.866z −1 + 0.5 0 0.5 0 −0. error = 2.a. (0.9)n u(n − 2) = n sin  π3n  = n sin u(n) + 0.62z −5 + 0.^n3).’FontSize’.43) -1. b = [0 sin(pi/3) (0.8z −4 − 0.9 4.81z −2 Z (0.81]. set(Hf_1. print -deps2 .delta).3.a).n2] = stepseq(0. [Hz. |z| > 1 1 − 2z −1 + 3z −2 − 2z −3 + z −4 1 − 0.9)n−2 u(n − 2) 3 πn  3 u(n) + 0.9)n−2 u(n − 2) h πn  i   X (z) = Z n sin u(n) + Z 0..9*sin(pi/3)+2.8 -4. |z| > 1 = −z + dz 1 − z −1 + z −2 1 − 0..81z −2 = + .’Name’.’linewidth’.Hl] = zplane(b.81z −6 = .1039e-014 The pole-zero plot is shown in Figure 4.5 2 Imaginary Part 1 0. [delta. title(’Pole-Zero plot’.1).5 2 −1 −1.0.3: Problem P4.*u3.’P0403c’).’off’. error = max(abs(xb1-xb2)) Hf_1 = figure.3.’linewidth’.9z −1 0./epsfiles/P0403c.5 −1 −0.n3] = stepseq(2.’NumberTitle’.. close all.81-0.7 2.9*sin(pi/3)) -(1.5 1 Real Part Figure 4.*u2+((0.81(0. Pole−Zero plot 1.0.Hp.8z −2 − 4.9)n−2 u(n − 2) 3 i   d  h πn  = −z Z sin u(n) + 0.0.9). x(n) = n sin( πn )u(n) + (0.7z −3 + 2. ’Name’.Hp. title(’Pole-Zero plot’. b = 3/2*[0 1 0 -4/9].5 0 0.Solutions Manual for DSP using Matlab (2nd Edition) 142 2006 4.0.4.delta). set(Hf_1. [delta. Pole−Zero plot Imaginary Part 1 0.8).*u.n2] = stepseq(1.^2). |z| > Matlab script: clc.’linewidth’.n1] = impseq(0.0. |z| > 4 4 −1 −2 dz 3 1 − 3z + 9z Let x3 (n) = n x2 (n) ⇒ X 3 (z) = −z z −1 − 49 z −3 d X 2 (z) = dz 1 − 83 z −1 + 83 z −2 − 32 z −3 + 27 16 −4 z 81 .’FontSize’./epsfiles/P0403d. [Hz.8). error = 9.a.5 4 0 −0.’linewidth’. set(Hz. a = [1 -8/3 8/3 -32/27 16/81]. print -deps2 . |z| > 2 3 Finally.’off’.4: Problem P4.*((2/3).7700e-015 The pole-zero plot is shown in Figure 4. x(n) = n 2 (2/3)n−2 u(n − 1): Consider 2 x(n) = n (2/3) n−2 Let −1 2 u(n − 1) = n (2/3) (2/3) (n−1) )#! " (  3 2 (n−1) u(n − 1) = u(n − 1) n n 2 3  (n−1) 2 z −1 2 x1 (n) = u(n − 1) ⇒ X 1 (z) = .1). [u.5 −1 −1 −0. x(n) = 32 x3 (n). xb2 = ((n2. error = max(abs(xb1-xb2)) Hf_1 = figure.Hl] = zplane(b.a).5 1 Real Part Figure 4.’P0403d’).’NumberTitle’. close all. |z| > 2 3 3 1 − 3 z −1 Let x2 (n) = n x1 (n) ⇒ X 2 (z) = −z d z −1 2 X 1 (z) = .4 pole-zero plot 2 3 .TFS). set(Hp.3. Hence 3 X (z) = 2 1− 8 −1 z 3 + z −1 − 49 z −3 8 −2 z 3 − 32 −3 z 27 + 16 −4 z 81 ! = 1− 3 −1 z − 23 z −3 2 8 −1 z + 83 z −2 − 32 z −3 3 27 + 16 −4 z 81 .^(n2-2)))..1). xb1 = filter(b. set(Hf_1.. |z| > 1 1 1 1 1 −2 −2 −2 −4 −2 dz 1 + 16 z 4 1 + 16 z 1 + 8 z + 256 z 1 + 16 z = −8z −1 − 32 z −3 − 1+ 3 −2 z 16 + 1 −5 z 16 . title(’Pole-Zero plot’.9). xb1 = filter(b.5 0 0.5 pole-zero plot .Hp.1).9392e-015 The pole-zero plot is shown in Figure 4.’NumberTitle’.5 0 -1/16].’Name’.TFS). error = max(abs(xb1-xb2)) Hf_1 = figure. |z| >  2 dz 4 2 4 1 − 2[ 14 cos(π/2)]z −1 + 41 z −2 ! 1 −1 z 4z −1 − 14 z −3 d 12 z −1 12 z −1 1 4 = −z − = − . set(Hz. set(Hp.’off’.0.5 1 Real Part Figure 4.5 3 0 3 −0.Hl] = zplane(b. x(n) = (n − 3)  1 n−2 4 cos π 2 143 (n − 1) u(n): Consider  n−2  n−2 nπ o nπ o 1 1 cos (n − 1) u(n) = (n − 3) sin n u(n) 4 2 4 2  −2  n  n nπ o nπ o 1 1 1 = (n − 3) sin sin n u(n) = 16(n − 3) n u(n) 4 4 2 4 2  n   nπ o nπ o 1 n 1 = 16 n sin n u(n) − 48 sin n u(n) 4 2 4 2 x(n) = (n − 3) Hence   n    n  nπ o nπ o 1 1 X (z) = Z 16 n sin sin n u(n) − Z 48 n u(n) 4 2 4 2    n  1 o n [ 4 sin(π/2)]z −1 d 1 π 1 Z n u(n) − 48 = −z sin .*((1/4).delta). error = 2.a).5 −1 −1 −0. print -deps2 . b = [0 -8 0 -1.9).’linewidth’.a.5: Problem P4. close all.n1] = impseq(0.’FontSize’.’P0403e’).^(n2-2))).*u. Pole−Zero plot Imaginary Part 1 0. [u.1). 3 −4 1 z + 4096 z −6 256 |z| > 1 4 Matlab script: clc.’linewidth’. a = [1 0 3/16 0 3/256 0 1/(256*16)]./epsfiles/P0403e.2006 Solutions Manual for DSP using Matlab (2nd Edition) 5. [Hz.*cos((pi/2)*(n2-1))).xb2 = (((n2-3).n2] = stepseq(0. [delta.0.3.5. 2π )n} u(n) = e−n e j 0.5952z −1 = + = 2 1 − e−1+ j 2π z −1 1 − e−1− j 2π z −1 2 1 − 0.7) (4.   ∗  1 1 1 + X R (z) = 2 1 − e−1+ j 2π z −1 1 − e−1+ j 2π z −∗     1 1 1 1 2 − 0.7) in (4.5952z −1 + 0.1353z −2 [(1/e) sin(0. respectively.2π )]z −1 0.2162z −1 X I (z) = = . Z [xI (n)] = Z = 2 2 ∗ ∗ X (z) − X (z ) = 2 (4. 1 − [(1/e) cos(0. Z [xR (n)] = Z = 2 2 X (z) + X ∗ (z ∗ ) = 2 and   Z [x(n)] − Z [x ∗ (n)] x(n) − x ∗ (n) X I (z) . The z-transform relations for real and imaginary parts.5952z −1 + 0.1).2π )]z −1 + (1/e2 )z −2 1 − 0.9) .2π )]z −1 1 − 0. |z| > 1/e Substituting (4.2π n)u(n) = (1/e)n cos(0.1353z −2 as expected in (4.3) (4.2976z −1 X R (z) = = .1) (4.2π n)u(n) xI (n) = e −n n sin(0. Substituting (4.8) (4.5952z −1 + 0. Similarly.2976z −1 = . |z| > e−1 1 − 0.5) (4.2π n)u(n) = (1/e) sin(0.2π n)u(n) with z-transforms .2162z = .2162z −1 = − = 2 1 − e−1+ j 2π z −1 1 − e−1− j 2π z −1 2 1 − 0.4) (4.2π n)u(n) + j sin(0. are xR (n) = e−n cos(0. Verification using x(n) = exp {(−1 + j 0.2π n i u(n) = 1 1− e−1+ j 0.2π n)u(n)} Hence the real and imaginary parts of x(n).5952z −1 + 0. |z| > e−1 1 − 0.1353z −2 1 − 0. 1.5952z −1 + 0.1353z −2 (4.2π z −1 .2) 2. (4. respectively.1353z −2 as expected in (4.6).144 Solutions Manual for DSP using Matlab (2nd Edition) 2006 P4.6) The z-transform of x(n) is X (z) = Z h e−1+ j 0.5).5952z −1 + 0.4 Let x(n) be a complex-valued sequence with the real part xR (n) and the imaginary part xI (n).2πn u(n) = e−n {cos(0.   ∗  1 1 1 X I (z) = − 2 1 − e−1+ j 2π z −1 1 − e−1+ j 2π z −∗     1 1 1 1 0.1353z −2 −1 0.2).2π )]z −1 + (1/e2 )z −2 1 − 0.2π )n} u(n): Consider x(n) = exp {(−1 + j 0. |z| > 1/e 1 − [(2/e) cos(0. |z| > 1/e 1 − [(2/e) cos(0.7) in (4.: Consider   x(n) + x ∗ (n) Z [x(n)] + Z [x ∗ (n)] X R (z) . 5z −1 1 + 0.5 The z-transform of x(n) is X (z) = 1/(1 + 0.5z −1 ).5z −2 2. The z-transforms of x1 (n) = x(3 − n) + x(n − 3): X 1 (z) = Z [x1 (n)] = Z [x(3 − n) + x(n − 3)] = Z [x{−(n − 3)}] + Z [x(n − 3)]   1 1 −3 −3 −3 .5z −1 1 + 0. 0. The z-transforms of x3 (n) =  1 n 2 x(n − 2):  n  1 x(n − 2) = Z [x(n − 2)]| 1 −1 = Z [x(n − 2)]|2z z 2 2  .5 < |z| < 2 = z X (1/z) + z X (z) = z + 1 + 0. |z| > 0.5 + 1.5z −3 + 2z −4 + 0. 1.25z −2 1 = − 2 − 4 = 4 .5z −1 X 2 (z) = Z  3.5 < |z| < 2 0.25z −1 + 0.5z −5 = .5z −2 1 − 0. The z-transforms of x2 (n) = (1 + n + n 2 )x(n):     d2 d 1 + n + n 2 x(n) = Z x(n) + n x(n) + n 2 x(n) = X (z) − z X (z) + z 2 2 X (z) dz dz 0. |z| ≥ 0.5z 1 + 0.5z −1 1 + 0.5z −1 z −1 + 0.5.5z −1 0. 0.2006 Solutions Manual for DSP using Matlab (2nd Edition) 145 P4.5 1 + 0. −2 −2 .  . z . = 0.25z = z −2 X (z) . |z| > 0.2z = .25 . |z| > 0.5 . 5 1 + 0. The z-transforms of x5 (n) = cos(π n/2)x ∗ (n):  e j πn/2 + e− j πn/2 X 5 (z) = Z cos(π n/2)x (n) = Z 2  j πn/2 ∗   − j πn/2 ∗  1 = Z e x (n) + Z e x (n) 2   . 1 + 0.5z −1 1 + 0.25z −1 2z X 3 (z) = Z 4. The z-transforms of x4 (n) = x(n + 2) ∗ x(n − 2):   X 4 (z) = Z [x(n + 2) ∗ x(n − 2)] = z 2 X (z) z −2 X (z) = X 2 (z) 1 = 2 .5z −1 5. |z| > 0. 1   ∗ . . = Z x (n) e− j π/2 z + Z x ∗ (n) . e j π/2 z 2  1  ∗ j π/2 ∗  = X e z + X ∗ e− j π/2 z ∗ 2  1 1 1 = + 2 1 + 0.25z −2  ∗   ∗ x (n)  .5e− j π/2 z −1 1 + 0. |z| > 0.5 1 + 0.5e j π/2 z −1 1 = . The z-transforms of x2 (n) = (1 + n + n 2 )x(n): X 2 (z) = Z or X 2 (z) =      d d2 1 + n + n 2 x(n) = Z x(n) + n x(n) + n 2 x(n) = X (z) − z X (z) + z 2 2 X (z) dz dz −1 + 1 z −2 + 1429 z −3 + 2399 z −4 + 215 z −5 + 829 z −6 − 167 z −7 − 7 z −8 − 2 z −9 − 1 z −10 1 + 17 3 z 2 108 72 1944 1944 144 243 1944 286 .5 1 + 5z −1 + 137 z −2 + 425 z −3 + 6305 z −4 + 2694 z −5 + 1711 z −6 + 449 z −7 + 1258 z −8 + 425 z −9 + 137 z −10 + 5 z −11 + 1 z −12 12 27 432 281 374 281 3103 5832 15552 7776 46656 n 3. The z-transforms of x1 (n) = x(3 − n) + x(n − 3): X 1 (z) = Z [x1 (n)] = Z [x(3 − n) + x(n − 3)] = Z [x{−(n − 3)}] + Z [x(n − 3)] " # 1+z 1 + z −1 −3 −3 −3 = z X (1/z) + z X (z) = z + . 0.6 The z-transform of x(n) is X (z) = 2006 1 + z −1 1 . The z-transforms of x3 (n) = 12 x(n − 2):  n  1 X 3 (z) = Z x(n − 2) = Z [x(n − 2)]| 1 −1 = Z [x(n − 2)]|2z z 2 2 1 −2  . |z| > 5 −1 1 −2 2 1 + 6z + 6z 1.5 < |z| < 2 6 + 35z −1 + 62z −2 + 35z −3 + 6z −4 2.5 < |z| < 2 1 + 56 z + 16 z 2 1 + 56 z −1 + 16 z −2 = 36z −1 + 72z −2 + 36z −3 . 0.Solutions Manual for DSP using Matlab (2nd Edition) 146 P4. |z| > 0. z + 18 z −3 4 = z −2 X (z) . |z| > 0.5]|2z = . The z-transforms of x4 (n) = x(n + 2) ∗ x(n − 2):   X 4 (z) = Z [x(n + 2) ∗ x(n − 2)] = z 2 X (z) z −2 X (z) = X 2 (z) = 1 + 2z −1 + z −2 5 −3 1 + 53 z −1 + 37 z −2 + 18 z + 36 1 −4 z 36 .25 5 −1 1 −2 1 + 12 z + 24 z 4. |z| > 0.2z = [. |z| > 0. The z-transforms of x5 (n) = cos(π n/2)x ∗ (n):  e j πn/2 + e− j πn/2 X 5 (z) = Z cos(π n/2)x (n) = Z 2  j πn/2 ∗   − j πn/2 ∗  1 = Z e x (n) + Z e x (n) 2   .5 5. 1   ∗ . . = Z x (n) e− j π/2 z + Z x ∗ (n) . e j π/2 z 2  1  ∗ j π/2 ∗  = X e z + X ∗ e− j π/2 z ∗ 2" # 1 1 − j z −1 1 + j z −1 = 2 1 − j 56 z −1 − 16 z −2 1 + j 56 z −1 − 16 z −2  = 1+ ∗ 2 + 43 z −2 13 −2 z 36 + 1 −4 z 36  . |z| > 0.5  ∗ x (n)  . Sequence computation Using the z-transform properties: 1.5 u(n) − 0. X 1 (z) = z−1 X (z): z Consider      1 x1 (n) = Z [X 1 (z)] = Z 1− X (z) = Z −1 X (z) − z −1 X (z) z n = x(n) − x(n − 1) = 0.2006 Solutions Manual for DSP using Matlab (2nd Edition) 147 P4. X 2 (z) = z X (z −1 ): Consider .5n u(n − 1) −1 −1 2.7 The inverse z-transform of X (z) is x(n) = (1/2)n u(n).5n−1 u(n − 1) = 1 − 0.  .   x2 (n) = Z −1 [X 2 (z)] = Z −1 z X (z −1 ) = Z −1 X (z −1 ) . n→(n+1) = Z −1 [X (z)]. 25)k . = k=−∞ P ∞ ∞ n k −k n −2n k 2 2 2 k=n (0. k=0 (0. n ≥ 0. 4 |n| 2 3 5.5) 2 . k=−∞ (0. n < 0. n ≥ 0. n < 0.25) .5)−(n+1) u(−n − 1) = 2n+1 u(−n − 1) 3.5)k u(k)2n−k u(−n + k) k=−∞ = =   n P∞ P k −k 2n P∞ 2 (0. X 5 (z) = z 2 d Xd z(z) : Consider x5 (n) = Z −1 [X 5 (z)] = Z = n 2 (1/2)n u(n) −1  z 2 d X (z) dz  = n 2 x(n) .5) 2 . X 4 (z) = X (z)X (z −1 ): Consider   x4 (n) = Z −1 [X 4 (z)] = Z −1 X (z)X (z −1 ) = x(n) ∗ x(−n) ∞ X     = 0.n→−(n+1) = (0. X 3 (z) = 2X (3z) + 3X (z/3): Consider x3 (n) = Z −1 [X 3 (z)] = Z −1 [2X (3z) + 3X (z/3)] = 2(3−n )x(n) + 3(3n )x(n)   n  n  1 3 −n −n n −n = 2(3 )(2 )u(n) + 3(3 )(2 )u(n) = 2 +3 u(n) 6 2 4.5n u(n) ∗ 2n u(−n) = (0. and x3 (n) are related by x3 (n) = x1 (n) ∗ x2 (n) then ! ! ∞ ∞ ∞ X X X x3 (n) = x1 (n) x2 (n) n=−∞ n=−∞ n=−∞ 1. Proof using the convolution property: Z [x3 (n)] = Z [x1 (n) ∗ x2 (n)] = Z [x1 (n)] Z [x2 (n)] !. Proof using the definition of convolution: ∞ X n=−∞ x3 (n) = = ∞ X n=−∞ x1 (n) ∗ x2 (n) = ∞ X n=−∞ x1 (n) ! ∞ X n=−∞ ∞ ∞ X X n=−∞ k=−∞ x2 (n) x1 (k)x2 (n − k) = ! ∞ X k=−∞ x1 (k) ! ∞ X n=−∞ as expected.8 If sequences x1 (n).Solutions Manual for DSP using Matlab (2nd Edition) 148 2006 P4. 2. x2 (n). !. !. ∞ ∞ . . . X X . . . x3 (n)z −n . = x1 (n)z −n . x2 (n)z −n . . . . x2 = rand(1. N = 1000.n1. 3.n2). sumx3 = sum(x3). x1 = rand(1.9104e-011 x2 (n − k) . sumx1 = sum(x1). [x3. n=−∞ n=−∞ z=1 z=1 n=−∞ z=1 ! ! ∞ ∞ ∞ X X X x3 (n) = x1 (n) x2 (n) ∞ X n=−∞ n=−∞ n=−∞ as expected.length(n1)). Matlab verification: clc.length(n2)). sumx2 = sum(x2).x2. n1 = [0:N]. n2 = [0:N].n3] = conv_m(x1. error = max(abs(sumx3-sumx1*sumx2)) error = 2. close all. [y2. y2 = [1 0 0 0 0 0 1].n2) x2 = 1 -2 3 2 1 0 1 -2 3 2 1 n = -5 -4 -3 -2 -1 0 1 2 3 4 5 Hence X 2 (z) = z 5 − 2z 4 + 3z 3 + 2z 4 + z + z −1 − 2z −2 + 3z −3 + 2z −4 + z −5 3.y1. X 2 (z) = (z 2 − 2z + 3 + 2z −1 + z −2 )(z 3 − z −3 ) % P0409b.n1.m clc. close all. X 3 (z) = (1 + z −1 + z −2 )3 % P0409c. n1 = [-2:2].n2] = conv_m(y1.2006 Solutions Manual for DSP using Matlab (2nd Edition) P4. n1 = [0 1 2].n1.y2. X 1 (z) = (1 − 2z −1 + 3z −2 − 4z −3 )(4 + 3z −1 − 2z −2 + z −3 ) % P0409a. n2 = [0:3].y2.n] = conv_m(y1. y1 = [1 -2 3 2 1].n2) x3 = 1 3 6 7 6 3 1 n = 0 1 2 3 4 5 6 Hence X 3 (z) = 1 + 3z −1 + 6z −2 + 7z −3 + 6z −4 + 3z −5 + z −6 149 . close all. [x2.n1.n] = conv_m(y1.n2) x1 = 4 -5 4 -2 -20 11 -4 n = 0 1 2 3 4 5 6 Hence X 1 (z) = 4 − 5z −1 + 4z −2 − 2z −3 − 20z −4 11 + z −5 − 4z −6 2. close all. [x3. y1 = [1 -2 3 -4].m clc. n2 = [-3:3].n1. n1 = [0:3].n] = conv_m(y1. y2 = [4 3 -2 1]. y1 = [1 1 1]. [x1.m clc.9 Polynomial operations using Matlab: 1.n1).y2. y2 = [4 2 3 1 0]. y21 = [1 -2 3 2 1]. y1 = [0 1 0 -3 0 2 0 5 0 -1]. [y41. [y23. [y33. n12 = [0:3].n32). y31 = [1 1 1].Solutions Manual for DSP using Matlab (2nd Edition) 150 4. n1 = [0:9]. [x4. y22 = [1 0 0 0 0 0 1].y12. y12 = [4 3 -2 1].n23).y22.n2) x5 = Columns 1 through 12 0 4 2 -9 -5 -1 1 26 12 11 3 -3 Columns 13 through 14 -1 0 n = Columns 1 through 12 -4 -3 -2 -1 0 1 2 3 4 5 6 7 Columns 13 through 14 8 9 Hence X 5 (z) = 4z 3 + 2z 2 − 9z 1 − 5 − z −1 + z −2 + 26z −3 + 12z −4 + 11z −5 + 3z −6 − 3z −7 − z −8 2006 . n2 = [-4:0].n31.n31.n22).y23.n12).n1.n13.m clc. X 5 (z) = (z −1 − 3z −3 + 2z −5 + 5z −7 − z −9 )(z + 3z 2 + 2z 3 + 4z 4 ) % P0409e.n] = sigadd(y41.n23] = conv_m(y21.n33) x4 = Columns 1 through 12 4 -13 26 -17 -10 49 -79 -8 23 -8 -11 49 Columns 13 through 17 -86 -1 -10 3 -4 n = Columns 1 through 12 -5 -4 -3 -2 -1 0 1 2 3 4 5 6 Columns 13 through 17 7 8 9 10 11 Hence X 4 (z) = 4z 5 − 13z 4 + 26z 3 − 17z 2 − 10z 1 + 49 − 79z −1 − 8z −2 + 23z −3 − 8z −4 − 11z −5 + 49z −6 − 86z −7 − z −8 − 10z −9 + 3z −10 − 4z −11 5.n] = conv_m(y1.m clc. n31 = [0 1 2].n41] = conv_m(y13.y31.n11. y11 = [1 -2 3 -4]. [y32.n33] = conv_m(y31.n31).y2.n21. n11 = [0:3]. n22 = [-3:3]. X 4 (z) = X 1 (z)X 2 (z) + X 3 (z) % P0409d. n21 = [-2:2]. close all. close all.n41.n13] = conv_m(y11.y33.y32. [y13. [x5.n32] = conv_m(y31. nr2 = nr1 + length(r)-1.na) p = 1 -1 2 -2 np = -1 0 1 2 r = 0 0 0 0 3 3 nr = -2 -1 0 1 2 3 Hence z 2 + z + 1 + z −1 + z −2 + z −3 3z −2 + 3z −3 −1 −2 = (z − 1 + 2z − 2z ) + z + 2 + z −1 z + 2 + z −1 151 .np.a. np1 = nb(1) . [p.r.a.nb.na) % % p = polynomial part of support np1 <= n <= np2 % np = [np1. Matlab verification: % P0410 clc.r. np = [np1:np2].r] = deconv(b.10 The Matlab function deconv_m: function [p. na = [-1:1]. na2] % [p. close all.a.r.np. a = [1 2 1].nb. np2] % r = remainder part of support nr1 <= n <= nr2 % nr = [nr1. nb2] % a = denominator polynomial of support na1 <= n <= na2 % na = [na1.np.nr] = deconv_m(b.na(1).a).nb. nr2] % b = numerator polynomial of support nb1 <= n <= nb2 % nb = [nb1. np2 = np1 + length(p)-1.2006 Solutions Manual for DSP using Matlab (2nd Edition) P4. nr1 = nb(1). nb = [-2:3]. nr = [nr1:nr2]. b = [1 1 1 1 1 1].nr] = deconv_m(b.nr] = deconv_m(b.na) % Modified deconvolution routine for noncausal sequences % function [p. 2500 k = -16 or 1 − z −1 − 4z −2 + 4z −3 1.1429 X 2 (z) = = −16 + − + .5238 -12.p. X 2 (z) = (1 + z −1 − 4z −2 + 4z −3 )/(1 − Matlab script: 11 −1 z 4 + 13 −2 z 8 − 14 z −3 ).a2) R = 1.25)n u(n) 2.11 Inverse z-transforms using the partial fraction expansion method: 1.1429 p = 2.Solutions Manual for DSP using Matlab (2nd Edition) 152 2006 P4.5z 1 − 0.a1) R = 0.k] = residuez(b1. there is a pole-zero cancellation.2500 k = -16 or X 1 (z) = 1 − z −1 − 4z −2 + 4z −3 0 10 27 = −16 + − + . b1 = [1. close all. [R. Hence x1 (n) = −16δ(n) − 10(0.-1. b2 = [1.-11/4.0000 p = 2.0000 27.5 < |z| > 2 11 −1 13 −2 1 −3 −1 −1 1 − 2z 1 − 0. % P0611b: Inverse z-Transform of X2(z) clc.6667 28.4]. a1 = [1.6667 28.-1/4].25z −1 1 − 4 z + 8 z − 4z Note that from the second term on the right. |z| > 0. The sequence is absolutely summable.-11/4.k] = residuez(b2.5z 1 − 0. a2 = [1.-4. [R.13/8.5 11 −1 13 −2 1 −3 −1 −1 1 − 2z 1 − 0.5000 0.0000 0.0000 0. X 1 (z) = (1 − z −1 − 4z −2 + 4z −3 )/(1 − Matlab script: 11 −1 z 4 + 13 −2 z 8 − 14 z −3 ). The sequence is right-sided. % P0611a: Inverse z-Transform of X1(z) clc.25z −1 1 − 4 z + 8 z − 4z .1.4].-1/4]. 0.p.5238 12.13/8.-4.5)n u(n) + 27(0.0000 -10. close all.5000 0. 2006 Solutions Manual for DSP using Matlab (2nd Edition) Hence x2 (n) = −16δ(n) − 1.5238(2)n u(−n − 1) − 12.6667(0.5)n u(n) + 28.1429(0.25)n u(n) 3. X 3 (z) = (z 3 − 3z 2 + 4z + 1)/(z 3 − 4z 2 + z − 0.16). The sequence is left-sided. Consider X 3 (z) = 1 − 3z −1 + 4z −2 + z −3 z 3 − 3z 2 + 4z + 1 = z 3 − 4z 2 + z − 0.16 1 − 4z −1 + z −2 − 0.16z −3 Matlab script for the PFE: % P0611c: Inverse z-Transform of X3(z) clc; close all; b3 = [1,-3,4,1]; a3 = [1,-4,1,-0.16]; [R,p,k] = residuez(b3,a3) % R = % 0.5383 % 3.3559 + 5.7659i % 3.3559 - 5.7659i % p = % 3.7443 % 0.1278 + 0.1625i % 0.1278 - 0.1625i % k = % -6.2500 r = abs(p(2)) % r = % 0.2067 [b,a] = residuez(R(2:3),p(2:3),[]) % b = % 6.7117 -2.7313 % a = % 1.0000 -0.2557 0.0427 or 0.5383 3.3559 + j 5.7659 + −1 1 − 3.7443z 1 − (0.1278 + j 0.1625)z −1 3.3559 − j 5.7659 + , |z| < 0.2067 1 − (0.1278 − j 0.1625)z −1 X 3 (z) = −6.25 + Hence x3 (n) = −6.25δ(n) − 0.5383(3.7443)n u(−n − 1) − (3.3559 + j 5.7659)(0.1278 + j 0.1625)n u(−n − 1) − (3.3559 − j 5.7659)(0.1278 − j 0.1625)n u(−n − 1) 153 Solutions Manual for DSP using Matlab (2nd Edition) 154 4. X 4 (z) = z/(z 3 + 2z 2 + 1.25z + 0.25), |z| > 1. Consider X 4 (z) = z −2 z = z 3 + 2z 2 + 1.25z + 0.25 1 + 2z −1 + 1.25z −2 + 0.25z −3 Matlab script for the PFE: % P0611d: Inverse z-Transform of X4(z) clc; close all; b4 = [0,0,1]; a4 = [1,2,1.25,0.25]; [R,p,k] = residuez(b4,a4) R = 4.0000 -0.0000 + 0.0000i -4.0000 - 0.0000i p = -1.0000 -0.5000 + 0.0000i -0.5000 - 0.0000i k = [] or X 4 (z) = Hence 4 4 4 0.5z −1 − = − 8z 2 2 , |z| > 1 1 + z −1 1 + z −1 1 + 0.5z −1 1 + 0.5z −1 x4 (n) = 4(−1)n u(n) − 8(n + 1)(0.5)n+1 u(n + 1) 5. X 5 (z) = z/(z 2 − 0.25)2 , |z| < 0.5. Consider X 5 (z) = z z −3 = , |z| < 0.5 (z 2 − 0.25)2 (1 − 0.25z −2 )2 Matlab script for PFE: % P0611e: Inverse z-Transform of X5(z) clc; close all; b5 = [0,0,0,1]; a5 = conv([1,0,-0.25],[1,0,-0.25]); [R,p,k] = residuez(b5,a5) R = 4.0000 + 0.0000i -2.0000 -4.0000 - 0.0000i 2.0000 + 0.0000i p = -0.5000 -0.5000 0.5000 + 0.0000i 0.5000 - 0.0000i k = [] 2006 2006 Solutions Manual for DSP using Matlab (2nd Edition) or 4 1 1 1 −2 −4 +2 , |z| < 0.5 −1 −1 2 −1 1 + 0.5z (1 + 0.5z ) 1 − 0.5z (1 − 0.5z −1 )2 4 (−0.5)z −1 1 0.5z −1 = + 4z − 4 + 4z , |z| < 0.5 1 − (−0.5)z −1 [1 − (−0.5)z −1 ]2 1 − 0.5z −1 (1 − 0.5z −1 )2 X 5 (z) = Hence x5 (n) = −4(−0.5)n u(−n − 1) − 4(n + 1)(−0.5)n u[−(n + 1) − 1] + 4(0.5)n u(−n − 1) − 4(n + 1)(0.5)n u[−(n + 1) − 1] = −4(−0.5)n u(−n − 1) − 4(n + 1)(−0.5)n u[−n − 2] + 4(0.5)n u(−n − 1) − 4(n + 1)(0.5)n u[−n − 2]     = 4(0.5)n 1 − (−1)n u(−n − 1) − 4(n + 1)(0.5)n 1 + (−1)n u(−n − 2) 155 Solutions Manual for DSP using Matlab (2nd Edition) 156 2006 P4.12 Consider the sequence given below: x(n) = Ac (r)n cos(π v0 n)u(n) + As (r)n sin(π v0 n)u(n) (4.10) 1. The z-transform of x(n) in (4.10): Taking z-transform of (4.10), 1 − r cos(π v0 )z −1 r sin(π v0 )z −1 + A s 1 − 2r cos(π v0 )z −1 + r 2 z −2 1 − 2r cos(π v0 )z −1 + r 2 z −2 Ac + r [As sin(π v0 ) − Ac cos(π v0 )] z −1 b0 + b1 z −1 = , ; |z| > |r| 1 − 2r cos(π v0 )z −1 + r 2 z −2 1 + a1 z −1 + a2 z −2 X (z) = Ac Comparing the last step above, we have b0 = Ac ; b1 = r[As sin(π v0 ) − Ac cos(π v0 )]; a1 = −2r cos(π v0 ); a2 = r 2 (4.11) 2. The signal parameters Ac , As , r, and v0 in terms of the rational function parameters b0 , b1 , a1 , and a2 : Using (4.11 and solving parameters in the following order: Ac , then r, then v0 , and finally As , we obtain Ac = b0 ; r= √ a2 ; v0 = arccos(−a1 /2r) ; π 3. Matlab function invCCPP: 2b1 − a1 b0 As = q 4a2 − a12 function [Ac,As,r,v0] = inv_CC_PP(b0,b1,a1,a2) % [Ac,As,r,v0] = inv_CC_PP(b0,b1,a1,a2) Ac = b0; r = sqrt(a2); w0 = acos(-a1/(2*r)); As = (b1/r+Ac*cos(w0))/sin(w0); v0 = w0/(pi); P4.13 Suppose X (z) is given as follows: X (z) = 2 + 3z −1 , |z| > 0.9 1 − z −1 + 0.81z −2 1. The signal x(n) in a form that contains no complex numbers: Matlab script: % P0413.m clc; close all; b0 = 2; b1 = 3; a1 = -1; a2 = 0.81; % (a): Computation of sequence parameters [Ac,As,r,v0] = invCCPP(b0,b1,a1,a2); disp(sprintf(’\nx(n) = %1i*(%3.1f)^n*cos(%5.4f*pi*n)u(n) ’,Ac,r,v0)); disp(sprintf(’ + %5.4f*(%3.1f)^n*sin(%5.4f*pi*n)u(n)\n’,As,r,v0)); x(n) = 2*(0.9)^n*cos(0.3125*pi*n)u(n) + 5.3452*(0.9)^n*sin(0.3125*pi*n)u(n) Hence x(n) = 2(0.9)n cos(0.3125π n)u(n) + 5.3452(0.9)n sin(0.3125π n)u(n) 2006 Solutions Manual for DSP using Matlab (2nd Edition) 157 2. Matlab verification: % (b) Matlab Verification n = 0:20; x = Ac*(r.^n).*cos(v0*pi*n) + As*(r.^n).*sin(v0*pi*n); y = filter([b0,b1],[1,a1,a2],impseq(0,0,20)); error = abs(max(x-y)) error = 1.7764e-015 P4.14 The z-transform of a causal sequence is given as: −2 + 5.65z −1 − 2.88z −2 1 − 0.1z −1 + 0.09z −2 + 0.648z −3 which contains a complex-conjugate pole pair as well as a real-valued pole. X (z) = 1. Rearrangement of X (z) into a first- and second-order sections: Matlab Script: % P0414 clc; close all; b = [-2 5.65 -2.88]; a = [1 -0.1 .09 0.648]; [R,p,k] = residuez(b,a) R = 1.0000 - 0.8660i 1.0000 + 0.8660i -4.0000 p = 0.4500 + 0.7794i 0.4500 - 0.7794i -0.8000 k = [] [b1,a1] = residuez(R(1:2),p(1:2),k) b1 = 2.0000 0.4500 a1 = 1.0000 -0.9000 0.8100 Hence X (z) = (2) + (0.45)z −1 (−4) + −1 −2 1 + (−0.9)z + (0.81)z 1 − (−0.8)z −1 2. Computation of the causal sequence x(n) from the X (z) so that it contains no complex numbers: Matlab Script: [Ac,As,r,v0] = invCCPP(b1(1),b1(2),a1(2),a1(3)); disp(sprintf(’\nx1(n) = %2.0f*(%3.1f)^n*cos(%5.4f*pi*n)u(n) ’,Ac,r,v0)); disp(sprintf(’ + %5.4f*(%3.1f)^n*sin(%5.4f*pi*n)u(n)\n’,As,r,v0)); x1(n) = 2*(0.9)^n*cos(0.3333*pi*n)u(n) + 1.7321*(0.9)^n*sin(0.3333*pi*n)u(n) Hence the sequence x(n) is: x(n) = 2(0.9)n cos(π n/3)u(n) + √ 3(0.9)n sin(π n/3)u(n) − 4(−0.8)n u(n) (4.12) Solutions Manual for DSP using Matlab (2nd Edition) 158 P4.15 System representations and input/output calculations: 1. h(n) = 5(1/4)n u(n) i. The system function: Taking the z-transform of h(n), 5 , |z| > 0.5 1 − 0.25z −1   H (z) = Z [h(n)] = Z 5(1/4)n u(n) = ii. The difference equation representation: From H (z) above, y(n) = 5x(n) + 0.25y(n − 1) iii. The pole-zero plot is shown in Figure 4.6. Pole−Zero plot Imaginary Part 1 0.5 0 −0.5 −1 −1 −0.5 0 0.5 1 Real Part Figure 4.6: Problem P4.15.1 pole-zero plot iv. The output y(n) for the input x(n) =  1 n 4 u(n): Taking the z-transform of x(n),   X (z) = Z (1/4)n u(n) = 1 , |z| > 0.25 1 − 0.25z −1 Now the z-transform of y(n) is    1 5 5 Y (z) = H (z)X (z) = = 2 , |z| > 0.25 −1 −1 1 − 0.25z 1 − 0.25z 1 − 0.25z −1 = 20z Hence 0.25z −1 1 − 0.25z −1 2 , |z| > 0.25 y(n) = 20(n + 1)(0.25)n+1 u(n + 1) 2006 2006 Solutions Manual for DSP using Matlab (2nd Edition) 159 2. h(n) = n(1/3)n u(n) + (−1/4)n u(n) i. The system function: Taking the z-transform of h(n)   H (z) = Z [h(n)] = Z n(1/3)n u(n) + (−1/4)n u(n) = = (1/3)z −1 1 − (1/3)z −1 1− 1 , |z| > (1/3) 1 + (1/4)z −1 2 + 1 − 13 z −1 + 5 −1 z 12 − 7 −2 z 36 , 1 −2 1 −3 z + 36 z 18 |z| > (1/3) ii. The difference equation representation: From H (z) above, 7 5 1 1 1 y(n) = x(n) − x(n − 1) + x(n − 2) + y(n − 1) + y(n − 2) − y(n − 3) 3 36 12 18 36 iii. The pole-zero plot is shown in Figure 4.7. Pole−Zero plot Imaginary Part 1 0.5 2 0 −0.5 −1 −1 −0.5 0 0.5 1 Real Part Figure 4.7: Problem P4.15.2 pole-zero plot iv. The output y(n) for the input x(n) =  1 n 4 u(n): Taking the z-transform of x(n),   X (z) = Z (1/4)n u(n) = 1 1− 1 −1 z 4 , |z| > 1 4 Now the z-transform of y(n) is Y (z) = H (z)X (z) = = = Hence 1− 5 −1 z 12 − −16 4 + 2 + 1 −1 1 − 3z 1 − 13 z −1 !   7 −2 z 1 36 , |z| 1 −2 1 −3 1 − 0.25z −1 z + 36 z 18 1 25 1 2 2 + , |z| > 1 −1 1 −1 3 1 + 4z 1 − 4z 1 − 13 z −1 + > 1 3 1 −1 1 25 z 1 −16 3 2 2 + 12z + + , |z| >  1 −1 2 1 1 3 1 − 3z 1 + 4 z −1 1 − 4 z −1 1 − 13 z −1 1 25 y(n) = −16( 13 )n u(n) + 12(n + 1)( 13 )n+1 u(n + 1) + (− 14 )n u(n) + ( 14 )n u(n) 2 2 8087 =z − .2198 − 0. Pole−Zero plot Imaginary Part 1 0.9) sin − 0.2198z − 2.5981 1 Y (z) = H (z)X (z) = . |z| > 0.2198(0.81z −2 1 − 0.2728z −1 + 0.8627(0.9 1.9)n cos(π n/4 + π/3)u(n + 1): Consider     10 π π(n + 1) n+1 h(n) = (0.81z −2 3.81z −2 ii.2198x(n + 1) − 2. |z| > 0.0000 − 1. The system function: Taking the z-transform of h(n)   1 − 0.3 pole-zero plot iv. h(n) = 3(0.2728z −1 + 0.2728z −1 + 0. The difference equation representation: From H (z) above.5981x(n) + 1.2728z −1 + 0.2728y(n − 1) − 0.9) cos (n + 1) u(n + 1) − sin (0. y(n) = 3.25z −1 |z| > 0.5 1 Real Part Figure 4.81z −2 1 − 1.9 1 − 1.9) sin (n + 1) u(n + 1) 4 4 i.5981 = .0285 − 2.5 0 −0.6364z −1 H (z) = Z [h(n)] = z 3.0285(0.6203z −1 0.81y(n − 2) iii.8: Problem P4.8.2198z − 2.2728z −1 + 0.9)n+1 sin (n + 1) u(n + 1) 3 12 4 3 12 4 hπ i hπ i n+1 n+1 = 3.0889(0.9 1 − 1. Now the z-transform of y(n) is    3.Solutions Manual for DSP using Matlab (2nd Edition) 160 2006 3. 1 − 0. |z| > 0.25.8087( 4 ) u(n+1) 4 4 .9) cos (n + 1) u(n + 1) − 0.81z −2 1 − 14 z −1 Hence       π(n + 1) π(n + 1) n+1 n+1 1 n+1 y(n) = 4.6364z −1 0.5 −1 −1 −0.5 0 0.9) cos − 0. The pole-zero plot is shown in Figure 4.15.9) cos + u(n + 1) 3 4 12   hπ hπ  π  i  π  i 10 10 n+1 = cos (0. The output y(n) for the input x(n) =  1 n 4 u(n): The z-transform of x(n) is X (z) = 1 .8627 1 − 1.25z −1 ! 4. 25.25z −2 H (z) = Z [h(n)] = ii.25z −1 + 0.25z −1 0. The output y(n) for the input x(n) =  1 n 4 u(n): The z-transform of x(n) is X (z) = 1 .5 0 −0.5 1 Real Part Figure 4. The difference equation representation: From H (z) above.5774 1 − 0. |z| > 0.5)n sin( π3 n)u(n) + 0.2887z = .5)n cos n u(n) 3 3 4.25z −2 1 − 0.5 0 0.2006 Solutions Manual for DSP using Matlab (2nd Edition) 161 (0. 1 − 0.5z −1 + 0.5z −1 + 0. y(n) = 0.5) + u(n) sin( π ) 3 3    3   hπ i  π  hπ i π 1 1 n n sin (0.5774x(n) + 0.5774 = − .5 −1 −2 1.2887z −1 1 Y (z) = H (z)X (z) = .5 1 − 0.5y(n − 1) − 0. Pole−Zero plot Imaginary Part 1 0.2887x(n − 1) + 0. Now the z-transform of y(n) is    0. |z| > 0.9: Problem P4.5 −1 −1 −0.4330z −1 1 − 0.25z −2 1 − 0.5) sin n u(n) + cos (0.5774( 14 )n u(n) 3 .5z −1 + 0.5z + 0. h(n) = i.5 1 − 0.25y(n − 2) iii. |z| > 0.5774z −1 0.25z 1 − 14 z −1 Hence y(n) = 4 (0.5)n sin n u(n) + 0.4 pole-zero plot iv.25z −1 |z| > 0.0000 − 0.5774 + 0.5774(0.5774 + 0.25z −2 −1 0.15.5)n sin[(n + 1)π/3] u(n): Consider sin(π/3) nπn π o i 1 h n h(n) = sin (0.5z −1 + 0. The pole-zero plot is shown in Figure 4.9.5) cos n u(n) = sin( π3 ) 3 3 sin( π3 ) 3 3 hπ i hπ i = (0. The system function: Taking the z-transform of h(n) 0.   X (z) = Z (1/4)n u(n) = 1 . |z| > 1 1 − z −1 1 − 0. h(n) = [2 − sin(π n)]u(n) = 2u(n) 2 .5 0 0. |z| > 0.5 −1 −1 −0.10. The pole-zero plot is shown in Figure 4.25 1 − 0.10: Problem P4.5 0 −0.15. |z| > 1 1 − z −1 1 − 14 z −1 Hence 8 2 y(n) = u(n) − 3 3  n 1 u(n) 4 2006 . The system function: H (z) = Z [h(n)] = Z [2u(n)] = Pole−Zero plot Imaginary Part 1 0.5 pole-zero plot iv. |z| > 1. 1 − z −1 ii. The output y(n) for the input x(n) =  1 n 4 u(n): Taking the z-transform of x(n). i.Solutions Manual for DSP using Matlab (2nd Edition) 162 5.5 1 Real Part Figure 4. The difference equation representation: y(n) = 2x(n) + y(n − 1) iii.25z −1 Now the z-transform of y(n) is    2 1 Y (z) = H (z)X (z) = .25z −1 8/3 2/3 = − . 25z − z 1 − 0.5z −1 Hence after taking inverse z-transform . h(n) is absolutely summable.6 0.4 ω/π 0. h(n).5 0 0 0 0. 1.2 0. Magnitude Response Phase Response 45 1 Degrees Magnitude 1.5z −1  2 1 − 0.2 0. Frequency response over 0 ≤ ω ≤ π is shown in Figure 4.5 30 15 0.16 frequency-response plot 0. Causality and stability: Since h(n) = 0 for n < 0.11: Problem P4.2006 Solutions Manual for DSP using Matlab (2nd Edition) 163 P4. Since h(n) is of finite duration (only two samples).5x(n − 1) X (z) 3.    1 1 jω = F [h(n)] = F δ(n) − δ(n − 1) = 1 − e− j ω H e 2 2 5. we obtain 1 h(n) = δ(n) − δ(n − 1) 2 2. Hence BIBO stable. Difference equation representation of the overall system: From the overall system function H (z).16 Consider the system shown below.6 0. The overall system impulse response.8 1 .8 1 0 0.11. H (z) = Y (z) = 1 − 0.5z −1 = = 1 − 0. the system is causal. Frequency response H e j ω of the overall system.5z −1 . |z| 6 = 0 1 − 0.  4.4 ω/π Figure 4.5z −1 ⇒ y(n) = x(n) − 0. using the z-transform approach: The above system is given by   1 −2 −1 H (z) = H2 (z) [1 + H1 (z)] = 1 + 0. y(n) = x(n) + x(n − 1) + 0.1 pole-zero plot iv.5)n−1 u(n − 1) ii.5z −1 1 − z −1 + z −2 1 − z −1 + z −2 √ 3 −1 √ z 1 − 0.5 −1 −1 −0.5z −1 1 − 0. |z| > 0. Consider H (z) = z+1 1 + z −1 1 z −1 = + .12.12: Problem P4. The output y(n) for the input x(n) = 3 cos(π n/3)u(n): Taking the z-transform of x(n). |z| > 1 −1 −2 −1 −2 −1 1−z +z 1−z +z 1 − z + z −2 Hence √ y(n) = 3 cos(π n/3)u(n) + 3 3 sin(π n/3)u(n) .5 1 − 0. The pole-zero plot is shown in Figure 4. h(n) = Z −1 [H (z)] = (0. |z| > 1 1 − [2 cos(π/3)]z −1 + z −2 1 − z −1 + z −2 Now the z-transform of y(n) is    1 + z −1 1 − 0.5z −1 1 − 0.5z −1 = 3 .5y(n − 1) iii.Solutions Manual for DSP using Matlab (2nd Edition) 164 2006 P4.5z −1 i.17. H (z) = (z + 1)/(z − 0.5 1 Real Part Figure 4.5).17 System representations and input/output calculations: 1.5z −1 1 + z −1 .5z −1 + 1.5)n u(n) + (0. X (z) = Z [3 cos(π n/3)u(n)] = 3 1 − [cos(π/3)]z −1 1 − 0. Pole−Zero plot Imaginary Part 1 0.5 0 −0. causal system. The impulse response: Taking the inverse z-transform of H (z).5z −1 2 =3 = 3 + 3 3 .5 0 0.5z −1 1 − 0. |z| > 1 Y (z) = H (z)X (z) = 3 = 3 1 − 0. The difference equation representation: From H (z) above.5 = z − 0. 7097 cos(π n/3)u(n) + 3.809 −1 −2 −1 1 + 0.5z −1 = 3 .7097 1 − 2 z 2 1.3524 sin(π n/3)u(n) 165 .2055 0.5z − 0.25z 1 + 0.0652 = −4 + + .9152 = − + + .309z −1 i.809)n u(n) + 4. H (z) = (1 + z −1 + z −2 )/(1 + 0. y(n) = x(n) + x(n − 1) + x(n − 2) − 0.13: Problem P4. |z| > 1 1 − [2 cos(π/3)]z −1 + z −2 1 − z −1 + z −2 Now the z-transform of y(n) is    1 + z −1 + z −2 1 − 0.5z −1 − 0. The difference equation representation: From H (z) above.25y(n − 2) iii.809)n u(n) − 0.5 1 Real Part Figure 4. The pole-zero plot is shown in Figure 4.309)n u(n) + 2.309)n u(n) ii.809z 1 − 0.3524 2.0652(0. Pole−Zero plot Imaginary Part 1 0.309z 1−z +z 1 − z + z −2 Hence y(n) = 1. The impulse response: Taking the inverse z-transform of H (z). |z| > 1 Y (z) = H (z)X (z) = 1 + 0.5z −1 − 0.5 0 0.25z −2 1 − z −1 + z −2 √   3 −1 1 −1 z 3. stable system.809z 1 − 0. X (z) = Z [3 cos(π n/3)u(n)] = 3 1 − [cos(π/3)]z −1 1 − 0.9348 4.5 0 −0. |z| > 1 −1 −1 −1 −2 −1 1 + 0.5z −1 3 .2055(−0.5y(n − 1) + 0.2006 Solutions Manual for DSP using Matlab (2nd Edition) 2.9348(−0. Consider H (z) = 1 + z −1 + z −2 0.25z −2 ).5 −1 −1 −0.13.2 pole-zero plot iv.17. |z| > 0. The output y(n) for the input x(n) = 3 cos(π n/3)u(n): Taking the z-transform of x(n). h(n) = Z −1 [H (z)] = −4δ(n) + 0.9152(0. |z| > 1 1 − [2 cos(π/3)]z −1 + z −2 1 − z −1 + z −2   1 − 0. The difference equation representation: From H (z) above. |z| > 1 2 + −1 −1 −2 −1 1 − 3z 21 1 − 3z −1 1−z +z 1 − z + z −2 y(n) = − 1 − z −2 1 − 6z −1 + 9z −2 43 n 20 36 3 u(−n − 1) − (n + 1)3n+1 u(−n − 2) − cos(π n/3)u(n) 49 21 49 193 + sin(π n/3)u(n) 1820 . The impulse response: Taking the inverse z-transform of H (z). Pole−Zero plot Imaginary Part 1.5z −1 3 .5 −1 0 1 2 3 Real Part Figure 4. Consider H (z) = z2 − 1 1 − z −2 1 2/9 8z 3z −1 = = − + +  .17. |z| < 3 (z − 3)2 1 − 6z −1 + 9z −2 9 1 − 3z −1 27 1 − 3z −1 2 i.14: Problem P4.5 1 0. The output y(n) for the input x(n) = 3 cos(π n/3)u(n): Taking the z-transform of x(n). H (z) = (z 2 − 1)/(z − 3)2 . anti-causal system.14.5z −1 = 3 . The pole-zero plot is shown in Figure 4. X (z) = Z [3 cos(π n/3)u(n)] = 3 Now the z-transform of y(n) is  Y (z) = H (z)X (z) = Hence 1 − [cos(π/3)]z −1 1 − 0.Solutions Manual for DSP using Matlab (2nd Edition) 166 2006 3.5 2 0 −0.3 pole-zero plot iv.5 −1 −1. 1 2 8 h(n) = Z −1 [H (z)] = − δ(n) − 3n u(−n − 1) − (n + 1)3n+1 u(−n − 2) 9 9 27 ii. y(n) = x(n) − x(n − 2) + 6y(n − 1) − 9y(n − 2) iii. 1 < |z| < 3 1 − z −1 + z −2 √   193 3 −1 −36 1 −1 −1 z 1 − 2z 20z 3z 1820 2 43/49 49 = + + . 5 0 0. stable system. X (z) = Z [3 cos(π n/3)u(n)] = 3 Now the z-transform of y(n) is !  1 − 0.25z 1 + 2z −1 H (z) = i.2006 Solutions Manual for DSP using Matlab (2nd Edition) 4.5z −1 .15. Pole−Zero plot Imaginary Part 1 0. 1 < |z| < 3 1 − z −1 + z −2 1 + 74 z −1 − 12 z −2 √   323 3 −1 1293 1 −1 z 1− z 2553 2 75/28 3/13 = − + 364 −1 2 −2 − .15: Problem P4.4 pole-zero plot iv. |z| > 1 1 −1 −1 −1 1 + 2z 1−z +z 1 − z + z −2 1 − 4z Y (z) = H (z)X (z) = Hence 1 − [cos(π/3)]z −1 1 − 0.25 < |z| < 2 −1 4 1 − 0.5 0 −0. |z| > 1 1 − [2 cos(π/3)]z −1 + z −2 1 − z −1 + z −2 2 + 54 z −1 + 18 z −2 3   75 n 3 1 n 1293 y(n) = − 2 u(−n − 1) − u(n) + cos(π n/3)u(n) 28 13 4 364 323 − sin(π n/3)u(n) 2553 167 . The difference equation representation: From H (z) above.5z −1 . 1 7 1 5 y(n) = 2x(n) + x(n − 1) − x(n − 2) − y(n − 1) + y(n − 2) 4 8 4 2 iii. The output y(n) for the input x(n) = 3 cos(π n/3)u(n): Taking the z-transform of x(n).  n 1 1 5 h(n) = Z −1 [H (z)] = − δ(n) + u(n) − 2n u(−n − 1) 4 4 4 ii. The pole-zero plot is shown in Figure 4. H (z) = z 1 − 0.5 −1 −2 −1.5 1 Real Part Figure 4.5z −1 = 3 . Consider + z − 0.17.25z −1 1 + 2z −1 1 + 74 z −1 − 12 z −2 1 1 5/4 =− + + .5 −1 −0.5z −1 + = 1 − 0.25 1 + 2z −1 2 + 54 z −1 + 18 z −2 1 1 − 0. 0. The impulse response: Taking the inverse z-transform of H (z). 5 pole-zero plot iv. X (z) = Z [3 cos(π n/3)u(n)] = 3 1 − [cos(π/3)]z −1 1 − 0. y(n) = x(n) + 2x(n − 1) + 3x(n − 2) + 2x(n − 3) + x(n − 4) iii.16. |z| > 1 .5 1 Real Part Figure 4. |z| > 0 i.5z −1 328 2553 √ 3 −1 z 2 #  1 − z −1 + z −2 . H (z) = (1 + z −1 + z −2 )2 . h(n) = Z −1 [H (z)] = {1.5 2 −1 −1 −0. Consider H (z) = (1 + z −1 + z −2 )2 = 1 + 2z −1 + 3z −2 + 2z −3 + z −4 . The impulse response: Taking the inverse z-transform of H (z). Pole−Zero plot Imaginary Part 1 2 0. 1} ↑ ii.16: Problem P4. The pole-zero plot is shown in Figure 4.17. 3. |z| > 1 Hence 3 3 3 1293 y(n) = 9δ(n) + δ(n − 1) − δ(n − 2) − δ(n − 3) + cos(π n/3)u(n) 2 2 2 364 328 − sin(π n/3)u(n) 2553 . |z| > 1 1 − [2 cos(π/3)]z −1 + z −2 1 − z −1 + z −2 Now the z-transform of y(n) is Y (z) = H (z)X (z) = 3 " 1 + 2z −1 + 3z −2 + 2z −3 + z −4 1 − z −1 + z −2 1293 364 3 3 3 = 9 + z −1 − z −2 − z −3 + 2 2 2 1−  1 − 12 z −1 z −1 + z −2 −  1 − 0.5 0 0. The output y(n) for the input x(n) = 3 cos(π n/3)u(n): Taking the z-transform of x(n).5z −1 = 3 . 2.Solutions Manual for DSP using Matlab (2nd Edition) 168 2006 5. The difference equation representation: From H (z) above.5 4 0 −0. 2. 5 −1 −2 −1.9)n u(n) 729 81 9 431 169 . 1 Y (z) 1 + 2z −1 + z −3 Y (z) = [X (z) + 2z −1 X (z) + z −3 X (z)] ⇒ H (z) = = 4 X (z) 4 ii.9z −1 Now the z-transform of y(n) is Y (z) = H (z)X (z) = =−  1 + 2z −1 + z −3 4  2 1 − 0.17: Problem P4. |z| > 0.9z −1 Hence y(n) = − 1310 50 5 990 δ(n) − δ(n − 1) − δ(n − 2) + (0.9)n u(n): Taking the z-transform of x(n).9z −1  .2006 Solutions Manual for DSP using Matlab (2nd Edition) P4.18.9 990 1310 50 −1 5 −2 431 − z − z + .5 1 Real Part Figure 4.17. The system function representation: Taking the z-transform of the above difference equation. Pole−Zero plot Imaginary Part 1 0. |z| > 0. |z| > 0.9 1 − 0.18 System representations and input/output calculations: 1.9)n u(n) = 2 . The impulse response: Taking the inverse z-transform of H (z). The output y(n) for the input x(n) = 2(0.1 pole-zero plot iv. y(n) = [x(n) + 2x(n − 1) + x(n − 3)] /4 i.   X (z) = Z 2(0. h(n) = 1 [δ(n) + 2δ(n − 1) + δ(n − 3)] 4 iii.9 729 81 9 1 − 0.5 −1 −0.5 3 0 −0.5 0 0. The pole-zero plot is shown in Figure 4. 9)n u(n) = 2 .5 0 0.809z −1 1 − 0.5z −1   .5z −1 Y (z) + 0.2617 0.9z −1 Now the z-transform of y(n) is    1 + 0.309)n u(n) + 2.25z −2 1 − 0.5 1 Real Part Figure 4.25y(n − 2) i.5 0 −0.309z −1 1 − 0.7567(0.5 −1 −1 −0.18.809)n u(n) + 0.309z −1 ii.809)n u(n) − 0.9 1 + 0.2764 1 + 0.18: Problem P4. Y (z) = X (z) + 0.495 = − + .9z −1 0.   X (z) = Z 2(0. The output y(n) for the input x(n) = 2(0.9 1 + 0.5x(n − 1) − 0.7567 2.809 = = X (z) 1 + 0.2617(−0.308)n u(n) iii.9)n u(n) .9)n u(n): Taking the z-transform of x(n).809z −1 1 − 0.7236 −1 −1   h(n) = Z =Z + 1 + 0.2 pole-zero plot iv. y(n) = x(n) + 0.5z −1 − 0.5z −1 0.809z −1 1 − 0. |z| > 0.809z −1 1 − 0.5y(n − 1) + 0.5z −1 2 Y (z) = H (z)X (z) = .18.9 1 − 0. |z| > 0. The impulse response: Taking the inverse z-transform of H (z).Solutions Manual for DSP using Matlab (2nd Edition) 170 2006 2. |z| > 0.25z −2 Y (z) or H (z) = 1 + 0.5z −1 X (z) − 0.5z −1 Y (z) 1 + 0. |z| > 0.25z −2 1 + 0.309z −1 = 0.9z −1 Hence y(n) = 0. " #   0.495(0.5z −1 − 0. The system function representation: Taking the z-transform of the above difference equation.7236(0.2764(−0.309z −1 1 + 0. Pole−Zero plot Imaginary Part 1 0. The pole-zero plot is shown in Figure 4. 19: Problem P4.9 9 1 − 0.9 1 − 0.19.5 0 −0. The output y(n) for the input x(n) = 2(0. Pole−Zero plot Imaginary Part 1 0. The system function representation: Taking the z-transform of the above difference equation. |z| > 0. h(n) = 2(0.9z −1 2 y(n) =  2 .9)n u(n) = 2 .5 1 Real Part Figure 4. |z| > 0.9z −1 Y (z) or H (z) = 2 Y (z) = . The pole-zero plot is shown in Figure 4.9z −1 40 (n + 1)(0.3 pole-zero plot iv. Y (z) = 2X (z) + 0.9y(n − 1) i. The impulse response: Taking the inverse z-transform of H (z).9 1 − 0. |z| > 0.9z −1  40 0.9z −1 ii.9z −1 Now the z-transform of y(n) is Y (z) = H (z)X (z) = = Hence  2 1 − 0.18.5 −1 −1 −0.5 0 0.9z −1 z  . |z| > 0.9)n+1 u(n + 1) 9 171 .9 X (z) 1 − 0.9)n u(n): Taking the z-transform of x(n).2006 Solutions Manual for DSP using Matlab (2nd Edition) 3. y(n) = 2x(n) + 0.9)n u(n) iii.   X (z) = Z 2(0. 4z + z 1.9z −1 ii.45 − 0. y(n) = −0.1097 1 + 0.4x(n − 1) + x(n − 2) + 0.4470(0.9z −1 Y (z) = H (z)X (z) = = Hence 1.9)n+1 u(n + 1) 2006 .20.4z −1 X (z) + z −2 X (z) + 0.9)n u(n) + 0.4z −1 − 0. The system function representation: Taking the z-transform of the above difference equation. The pole-zero plot is shown in Figure 4.45X (z) − 0. |z| > 0.45z −2 Y (z) or H (z) = Y (z) −0.5z −1 1 − 0.4z −1 − 0.   X (z) = Z 2(0.9z −1 Now the z-transform of y(n) is   −0.45 − 0.9 1 − 0.9 1 − 0.20: Problem P4.1097(−0.9)n u(n) = 2 .9z −1 2. |z| > 0.5 1 Real Part Figure 4.4 pole-zero plot iv.5 0 0.5z −1 1 − 0.4z −1 + z −2 −0.45 − 0.4859(n + 1)(0. The output y(n) for the input x(n) = 2(0.5536(−0.9z −1 1 + 0. Y (z) = −0.4859z 2 .45y(n − 2) i.4z −1 Y (z) + 0. The impulse response: Taking the inverse z-transform of H (z).45 − 0.Solutions Manual for DSP using Matlab (2nd Edition) 172 4.4y(n − 1) + 0.5z −1  y(n) = 1.9)n u(n) 9 iii.9z −1 1 − 0.5536 0.4z −1 + z −2 2 .5)n u(n) + 0.4470 0.9)n u(n): Taking the z-transform of x(n).9z −1 − + 0.5 −1 −0.2187 −1 −1   =Z h(n) = Z − + + 9 1 + 0.9z −1 =− 20 δ(n) + 1. |z| > 0.5 0 −0.4z −1 + z −2   .45z −2 1 − 0.45x(n) − 0.5 −1 −2 −1. Pole−Zero plot Imaginary Part 1 0.5)n u(n) − 2.5z −1 1 − 0.18.9 = = X (z) 1 − 0.9 1 − 0. " #   −1 −2 20 −0. |z| > 0.45z −2 1 + 0.2187(0. 6561z −4 1 − 0.5 pole-zero plot iv.5 −1 −1 −0.9)n u(n): Taking the z-transform of x(n). The impulse response: Taking the inverse z-transform of H (z).9z −1 0.1◦ ) u(n) iii.8π n + 1.81z −2 1 + 1.9 1 − 0. The pole-zero plot is shown in Figure 4.8z −1 + 0. |z| > 0.9)n u(n) .81z −2 ii.8)m z −m X (z) − 4 X (0.9◦ )u(n) + 1.8) m x(n − m) − P4 ℓ=1 (0.21.37◦ )u(n) + 0.4562z −1 + 0. Y (z) = or H (z) = P4 4 X m=0 (0.4562z + 0.9 = 1 − 0.512z −3 + 0. The output y(n) for the input x(n) = 2(0.9)ℓ z −ℓ Y (z) ℓ=1 m −m Y (z) m=0 (0. Pole−Zero plot Imaginary Part 1 0.2081 + 0. |z| > 0.1884δ(n) + 0.9) ℓ 173 y(n − ℓ) i.1873 + 0.6023(0.4π n + 4.9z −1 Now the z-transform of y(n) is    1 + 0.6243 + h(n) = Z + 1 − 0.3197(0.9)ℓ z −ℓ 1 + 0.8) z = P4 X (z) 1 + ℓ=1 (0.1498z −1 0.4096z −4   .9) cos(0.512z −3 + 0.5 1 Real Part Figure 4.4096z −4 2 Y (z) = H (z)X (z) = 1 + 0.81z −2   n = 0.6023 = + + . |z| > 0.9)n cos(0.5562z −1 + 0.1896 + 0.8π n − 16.5 0 0. The system function representation: Taking the z-transform of the above difference equation.81z 1 − 0.9z −1 Hence y(n) = 0.18.4π n − 49.   X (z) = Z 2(0.9z −1 + 0.21: Problem P4.9 −1 −2 −1 −2 1 − 0.1885(0.   0.81z 1 + 1.1685z −1 1.9)n cos(0.2006 Solutions Manual for DSP using Matlab (2nd Edition) 5.64 + z −2 + 0.9)n cos(0.0651z −1 0. y(n) = P4 m=0 (0.9)n u(n) = 2 .1884 + 0.5 0 −0.1879(0.8z −1 + 0.1982(0.279z −3 + 0.81 + z −2 + 0.4562z −1 + 0.63◦ ) + 0.81z −2 1 + 1.5562z + 0.1353z −1 −1 0.64 + z −2 + 0.5562z −1 + 0. 18. Particular part: Hence the total response is the particular part.9)n u(n) 729 81 9 431 iii. y(n) = x(n) + 0.19 Separation of the total response y(n) into (i) the homogeneous part.7567(0. Thus yh (n) = 0.809)n u(n) − 0. Particular part: Since the system pole and the input pole are the same and hence are indistinguishable.9)n+1 u(n + 1) 9 ii.2617(−0. 1.9)n+1 u(n + 1) 9 . hence yh (n) = 0. Homogeneous part: The first two terms in y(n) are due to the system poles.2617(−0.809)n u(n) − 0.7567(0.309)n u(n) ii.9y(n − 1): The total response is y(n) = 40 (n + 1)(0.9)n u(n) 729 81 9 431 i. ytr (n) = 0. 2. y(n) = [x(n) + 2x(n − 1) + x(n − 3)] /4: The total response is y(n) = − 1310 50 5 990 δ(n) − δ(n − 1) − δ(n − 2) + (0. Therefore. Steady-state response: Clearly. (ii) the particular part. Particular part: The last term in y(n) is due to the input pole.495(0. the homogeneous equation is y(n) = 0.5x(n − 1) − 0.2617(−0. Transient response: Since the entire response decays to zero. the total response can be equally divided into two parts or yp (n) = 20 (n + 1)(0. ii. or yp (n) = − 1310 50 5 990 δ(n) − δ(n − 1) − δ(n − 2) + (0. (iii) the transient response. the total response can be equally divided into two parts or yh (n) = 20 (n + 1)(0. hence yp (n) = 2. yss(n) = 0. and (iv) the steady-state response for each of the systems given in Problem P4.174 Solutions Manual for DSP using Matlab (2nd Edition) 2006 P4. Therefore. ytr (n) = − 50 5 990 1310 δ(n) − δ(n − 1) − δ(n − 2) + (0.9)n u(n) iv.9)n u(n) i.495(0.25y(n − 2): The total response is y(n) = 0.9)n u(n) iii.5y(n − 1) + 0.309)n u(n) + 2. yss(n) = 0.7567(0.309)n u(n) + 2.809)n u(n) − 0. Homogeneous part: Since the system pole and the input pole are the same and hence are indistinguishable. Steady-state response: Clearly.9)n u(n) 729 81 9 431 iv. y(n) = 2x(n) + 0. 3. Homogeneous part: Since the system is an FIR filter. Transient response: Since all poles of Y (z) are inside the unit circle.495(0.9)n+1 u(n + 1) 9 i. hence yh (n) = 0. y(n) = 4m=0 (0.5)n u(n) − 2.1982(0.9)ℓ y(n − ℓ): The total response is y(n) = 0.24295(n + 1)(0.1135(0.1135(0.9)n u(n) + 0.4470(0.6023(0.8)m x(n − m) − 4ℓ=1 (0. Particular part: The last term in y(n) is due to the input pole.37◦ )u(n) + 0. ytr (n) = 0.4470(0.9)n cos(0.45x(n) − 0.2006 Solutions Manual for DSP using Matlab (2nd Edition) 175 iii. Hence the response due to p2 has to be divided to include in both parts.9◦ )u(n) + 1.9)n cos(0.9)n u(n) + 0.9)n u(n) + 0.1982(0. p2 is also an input pole.5)n u(n) − 1.9)n u(n) i.4π n − 49.9)n u(n) iv.4π n − 49.4859(n + 1)(0.9)n cos(0. P P 5.37◦ )u(n) + 0.9)n cos(0.9)n+1 u(n + 1) iii.24295(n + 1)(0.6023(0. hence yp (n) = 1. yss(n) = 0. 4.37◦ )u(n) + 0.9)n+1 u(n + 1) 9 iv. Steady-state response: Clearly. p1 = −0.9◦ )u(n) + 1. yss(n) = 0. Hence yh (n) = 1. Homogeneous part: The first two terms in y(n) are due to the system poles.9. Steady-state response: Clearly.9)n cos(0. Transient response: Since all poles of Y (z) are inside the unit circle.8π n − 16. Steady-state response: Clearly.6023(0.1097(−0.3197(0. ytr (n) = 40 (n + 1)(0.3197(0.4y(n − 1) + 0.9)n+1 u(n + 1) iv.9)n+1 u(n + 1) i.5 and p2 = 0. Particular part: from above.1982(0.4859(n + 1)(0.9)n cos(0. .9)n u(n) iii.4π n − 49. Homogeneous part: There are two system poles.45y(n − 2): The total response is y(n) = 1.8π n − 16.3197(0.5)n u(n) − 2.8π n − 16. ytr (n) = 1. y(n) = −0.9◦ )u(n) ii. Transient response: Since all poles of Y (z) are inside the unit circle. yp (n) = −1.4x(n − 1) + x(n − 2) + 0.1097(−0.1097(−0. Transient response: Since all poles of Y (z) are inside the unit circle.9)n u(n) + 0. yss(n) = 0.9)n+1 u(n + 1) ii. Clearly. 6561z −4 # 1 − √12 z −1 √ 1 − 2z −1 + z −2 ! 1 − √12 z −1 0.0351(0.6561e j π  0. The steady-state response yss (n) for the input x(n) = cos(π n/4)u(n): From the z-transform table.9z −1 The first term above has poles on the unit circle and hence gives the steady-state response yss(n) = cos(π n/4) 4.20 A stable system has the following pole-zero locations: zeros: ± 1.8281x(n) − 0.9)n sin(π n/2)u(n) .9.0351 0. Using the inv_CC_PP function we have Ytr (z) = − 0.0351 0.9 = 1.6561y(n − 4) 3. 1.1509 .2077 ⇒ K = 0. we have H e j π/4 = 1.0860 − 0. |z| > 0.9z −1 − − 0.086(0.8281x(n − 4) + 0.9)n u(n) − 0.9 H (z) = 1 − 0.0509 1 0.8281 1 − 0. |z| > 1 1 − 0. The system function H (z) and its region of convergence: Consider 1 − z −4 (z − 1)(z + 1)(z − j )(z + j ) =K .9)(z − j 0.81z −2 1 − 0.0860 − 0.9)n u(n) − 0.9 (z − 0.0509 −0.1358z −1 = − − + . |z| > 1 √ 1 − 0.6561z −4  Now at z = e j π/4.81z −2 Hence ytr (n) = −0. The transient response ytr (n) for the input x(n) = cos(π n/4)u(n): The remaining terms in y(n) are the transient response terms. ± j 0.6561z −4 2.6561z −4 X (z) we have y(n) = 0. |z| > 0.8281 1 − z −4 Y (z) H (z) = = 1 − 0.9)(z + 0. Hence H (z) = K  1 = H e j π/4 = K or 1 − e jπ = K × 1.9z −1 1 − 0.9z −1 1 + 0.9)n cos(π n/2)u(n) − 0.Solutions Manual for DSP using Matlab (2nd Edition) 176 2006 P4.0509(−0.81z −2 1 − 2z −1 + z −2 1 − 0. ± j 1 It is also known that H e  j π/4 Poles: ± 0.9)(z + j 0/9) 1 − 0.9z −1 1 + 0.1509(0.8281 1 − z −4 . 1 − √12 z −1 1 − [cos(π/4)]z −1 X (z) = = √ 1 − [2 cos(π/4)]z −1 + z −2 1 − 2z −1 + z −2 Hence Y (z) = H (z)X (z) = " 0.8281 1 − z −4 1 − 0. The difference equation representation: From  0. subplot(2. Hs = stem(n.x).2 frequency-response plots √ The magnitude and phase at ω = π/2 are 2 and −45◦ .22: Problem P4. ’FontSize’. y = filter(b.’off’.21.’FontSize’.. .21 A digital filter is described by the frequency response function H (e j ω ) = [1 + 2 cos(ω) + 3 cos(2ω)] cos(ω/2)e− j 5ω/2 which can be written as   j 2ω  j 1 ω 1 e j ω + e− j ω e + e− j 2ω e 2 + e− j 2 ω − j 5 ω H (e ) = 1 + 2 +3 e 2 2 2 2 3 5 5 3 = + e− j ω + e− j 2ω + e− j 3ω + e− j 4ω + e− j 5ω 4 4 4 4 jω   or after substituting e− j ω = z −1 .2). axis([-2 202 -2 4]). set(Hf_1.’defaultfigurepaperposition’.25 0.a.5 ω/π 0.TFS).LFS).75 1 Figure 4.2).5 ω/π 0. The difference equation representation: From H (z) above y(n) = 3 5 5 3 x(n) + x(n − 1) + x(n − 2) + x(n − 3) + x(n − 4) + x(n − 5) 4 4 4 4 2. 3. ylabel(’y(n)’. close all.’NumberTitle’. Hs = stem(n. Magnitude Response Phase Response 180 4 Degree Magnitude 6 0 −45 2 1.5]).LFS).’markersize’. Hf_1 = figure. we obtain H (z) = 3 5 −1 5 3 + z + z −2 + z −3 + z −4 + z −5 4 4 4 4 1.y).’FontSize’. axis([-2 202 -7 6]).0.’P0421c’). set(0.x). a = [1 0].. subplot(2. set(Hs.1). xlabel(’n’./epsfiles/P0421c.25 0.75 1 0 0.7. print -deps2 .1.2). respectively.’FontSize’. title(’Output sequence after filtering’.LFS)..2006 Solutions Manual for DSP using Matlab (2nd Edition) 177 P4.’FontSize’.41 0 −180 0 0.’markersize’. The magnitude and phase response plots are shown in Figure 4.’FontSize’. set(Hs.LFS).[0.. The output sequence y(n) for the input x(n) = sin(π n/2) + 5 cos(π n): Matlab script: clc. n = 0:200. ylabel(’x(n)’. title(’x(n) = sin(\pi \times n / 2)+5 \times cos(\pi \times n)’. xlabel(’n’.’Name’.1.22. b = [3/4 5/4 1 1 5/4 3/4]. x = sin(pi*n/2)+5*cos(pi*n).TFS). The magnitude at ω = π is zero. Solutions Manual for DSP using Matlab (2nd Edition) 178 2006 The input and output sequence plots are shown in Figure 4. .23. It shows that the sinusoidal sequence with the input frequency ω = π is completely suppressed in the steady-state output. above) √ √ √ yss (n) = 2 sin(π n/2 − 45◦ ) = 2 cos(45◦ ) sin(π n/2) − 2 sin(45◦ ) cos(π n/2) = sin(π n/2) − cos(π n/2) = {. x(n) = sin(π × n / 2)+5 × cos(π × n) 6 4 x(n) 2 0 −2 −4 −6 0 20 40 60 80 100 120 140 160 180 200 160 180 200 n Output sequence after filtering 4 3 y(n) 2 1 0 −1 −2 0 20 40 60 80 100 120 140 n Figure 4. .21. −1. . −1. The steady-state response of x(n) = sin(π n/2) should be (using the magnitude and phase at ω = π/2 computed in part 2. 1. −1. . 1.23. .} ↑ as verified in the bottom plot of Figure 4. .23: Problem P4.3 input and output sequence plots . 1.’FontSize’. The difference equation representation: From H (z) above y(n) = x(n) + x(n − 4) + 0.8145z −4 1.’markersize’.’off’. set(Hs.The steady-state response of x(n) should be (using the magnitude and phase at ω = π/2 computed in part 2. close all.’FontSize’. set(0. y = filter(b. ylabel(’x(n)’. respectively.5 ω/π 0..’Name’. The magnitude and phase response plots are shown in Figure 4.a.LFS).25.’markersize’.’FontSize’. a = [1 0 0 0 -0. print -deps2 . axis([-2 202 -7 7]).’NumberTitle’..78 sin(π n/2) + 10. 3. Hs = stem(n. b = [1 0 0 0 1].TFS)..91cos(π n/2) .2).2 frequency-response plots The magnitudes and phases at both ω = π/2 and ω = π are 10.7.1). title(’Output sequence after filtering’.TFS).2). Magnitude Response Phase Response 180 10. The input and output sequence plots are shown in Figure 4.5 ω/π 0. subplot(2. Hs = stem(n.’P0422c’).78sin(π n/2) + 53.LFS).y). x = sin(pi*n/2)+5*cos(pi*n). ylabel(’y(n)’.’FontSize’./epsfiles/P0422c. The output sequence y(n) for the input x(n) = sin(π n/2) + 5 cos(π n): Matlab script: clc.78 × 5 cos(π n) = 10.1.x). set(Hs. ’FontSize’.78 10 Degree Magnitude 90 5 0 −90 0 −180 0 0.24.’defaultfigurepaperposition’.0.8145].. subplot(2.8145y(n − 4) 2.[0. xlabel(’n’.75 1 0 0.’FontSize’.25 0.24: Problem P4.5]). xlabel(’n’. above) yss(n) = 10.78 and 0◦ .22.LFS).2006 Solutions Manual for DSP using Matlab (2nd Edition) 179 P4.75 1 Figure 4. title(’x(n) = sin(\pi \times n / 2)+5 \times cos(\pi \times n)’. set(Hf_1.22 A digital filter is described by the frequency response function H (e j ω ) = which after substituting e− j ω = z −1 becomes H (z) = 1 + e− j 4ω 1 − 0.x). axis([-2 202 -70 70]).2). Hf_1 = figure.LFS).25 0. n = 0:200.8145e− j 4ω 1 + z −4 1 − 0. x(n) = sin(π × n / 2)+5 × cos(π × n) 6 4 x(n) 2 0 −2 −4 −6 0 20 40 60 80 100 120 140 160 180 200 160 180 200 n Output sequence after filtering 60 40 y(n) 20 0 −20 −40 −60 0 20 40 60 80 100 120 140 n Figure 4.78 and no delay distortion.25 shows that both sinusoidal sequences have the scaling of 10.Solutions Manual for DSP using Matlab (2nd Edition) 180 2006 The bottom plot of Figure 4.3 input and output sequence plots .25: Problem P4.22. 7n u(n)] = 1 .nb2. n ≥ 0. na2 = [0 1 2].na2).81z −1 1 − 0. [R.0000-0. b1 = [1 -1].81z −1 1 − 0.81y(−1)z −1 + X (z) + 1 − 0.nbnr2] = conv_m(b2. na11 = [0 1 2].7)n u(n).23 Difference equation solution using the one-sided z-transform approach.81z 1 − 0. we obtain 1 − 0. y(−2) = 2 (0.81y(−1)z −1 or Y + (z) = 1 − z −1 [0. a2 = [1 0 -0. nb2 = [0 1].7457+0.nb] = sigadd(bnr1.4860z −1 − 1.na11. na12 = [0 1].7) u(n + 1) =  y(−1) = 2.1914 + 1.nbnr1] = conv_m(b1. [bnr2.81z −1 After substituting the initial conditions and X + (z) = Z [0.p.62].7)−1 .81].na1.7z −1 1 − 0. n ≥ 0.4642(0. [a.7].0000i 0.6562 p = 181 .k] = residuez(b. [b. y(n) = 0.nbnr1. a12 = [1 -0.81z 1 − 0.81y(−2) − x(−1)] + 0.a1.na] = conv_m(a1. nb1 = [0 1].nbnr2).a).1914 + 0.81y(−2) − x(−1)] + 0. [a1.1914 1.7273   = =2+ + −1 −1 −1 1 − 0. After taking the one-sided z-transform of the above difference equation.7)n u(n + 1) Notice that n x(n) = (0. we obtain     Y + (z) = 0. b2 = [0.0000 0.81y(n − 2) + x(n) − x(n − 1). n = −1.1340z −2 0.a12.0000i 0.81)n u(n) + 2.7)n u(n) Matlab verification: clc.81z −1 1.62z −1 Y (z) = + 1 − 0.81z −2 Y + (z) + 1 − z −1 X + (z) + [0.na1] = conv_m(a11. x(n) = (0. close all. (0.7273(0.a2.0000i 0. a11 = [1 0 -0.81 y(−2) + y(−1)z −1 + z −2 Y + (z) + X + (z) − x(−1) + z −1 X + (z)   = 0.4642 2.na2).7z −1 1 − 0.bnr2.7z +  Hence upon inverse transformation y(n) = 2δ(n) + 0.na12).81]. [bnr1.2106-0.nb1.7z −1   1 − z −1 1 0.na1).2006 Solutions Manual for DSP using Matlab (2nd Edition) P4.a2. R = -0. x. x = 0.^n)+R(3)*((p(3)).62].9000 0.^n.^n).0000i 0.9000+0. yb2 = R(1)*((p(1)).xic).a11.9000 -0.1914 1.9000-0. error = max(abs(yb1-yb2)) error = 6.^n)+R(5)*((p(5)). yb1 = filter(b1.Solutions Manual for DSP using Matlab (2nd Edition) 182 -0.7000 k = [] n = [0:20]. xic = [0.2150e-008 2006 .0000i 0.7. 5z −1    0.9z −1 1 + 0. we obtain Y + (z) − 0.45x(n) + 0.4z −1 − 0.9)n + 1.15 − 2z −1    + = (4.13).45 + 0. Hence yss (n) = −2.2006 Solutions Manual for DSP using Matlab (2nd Edition) 183 P4.3321(0.1116(0.45z −2 h i n 2 1 After substituting the initial conditions and X + (z) = Z [2 + 12 ]u(n) = + .4z − 0.15 − 2z −1 Y + (z) = + + 1 − 0.4y(−1) + 0.45 + 0.4438 1.45z −2 Y + (z) = 0.3303(−0.5)n u(n) + YZS (z) = or . Taking the one-sided z-transform of the difference equation.45y(−1)z −1 − 0. the last term on the right corresponds to the initial condition or zero-input response. the part of y(n) that decays to zero as n ր ∞.5)n − 0.45z −2 −1 −2 −3 1. y(−2) = 3.9)n + 1.5z 1 + 0. n ≥ 0: Given y(n) − 0.45z 1 − 0.7188 0.5z −1 1 − z −1 1 − 0.4y(n − 1) − 0.5)n u(n) + (z) = YZI or (d) Zero-state response: In (4.3z − 3.5)n − 1.3304 = + + − 1 − z −1 1 − 0.5z −1 1 − 0. Hence 1.7187 1.35 + 0.7188(0.9z −1 1 + 0.9z 1 + 0.4x(−1) − x(−2)] + [0.45y(−2) − 0.5z −1 −2 3.5z −1 1 − z −1 1 − 0.45z −2 1 − 0.4x(−1) + 0.7188(0.475z −3 − 0.4z −1 − 0.65z −2 + 0.35 + 0.15 − 2z −1 −1.5)n u(n) (b) Steady-state response: This response is due to poles on the unit circle.45y(−2) + 0.4z −1 − z −2 + X (z) 1 − 0.5)n − 0.4z −1 − 0.4z −1 − z −2 2 1 0.225z −4 −2 2.8125 = + + − −1 −1 −1 1−z 1 − 0.4z −1 X + (z) − x(−2) − x(−1)z −1 − z −2 X + (z) or 0.9z −1 + 0.725z −2 + z −3 1 − 1.5z −1   yZS (n) = −2 + 3.925z −1 − 0.9z −1 1 − 0.45z −2 1 − z −1 1 − 0.9)n + 1.45X + (z) + 0.24 Difference equation solution for y(n).45y(n − 2) = 0.4821(−0.13).3z −1 − 3.8z −2 + 2z −3     1 − 0.5 − 1.5z −1 1 + 0.4x(n − 1) − x(n − 2) n driven by the input x(n) = 2 + 12 u(n) and subject to y(−1) = 0.45z −2 [0.4z −1 − 0.4438(0.9)n + 1.5z −1   yZI (n) = −1.5z −1 Hence after inverse transformation   y(n) = −2 + 2.5z −1 Y + (z) = 1.13) 1 − 0.1116(0.4821 = + −1 −2 −1 1 − 0. Hence 0.3321 1.3303(−0.4z −1 − 0.8125(−0.1116 1. (c) Zero input response: In (4.45y(−1) − x(−1)]z −1 + 1 − 0. we obtain −1 1−z 1 − 0. x(−1) = x(−2) = 2.7187(0.4z −1 Y + (z) − 0. the first term on the right corresponds to the input excitation or is the zero-state response. Thus   ytr (n) = 2.4y(−1) − 0.5)n u(n) = (a) Transient response: This response is due to the poles inside the unit circle or equivalently.8z + 2z 0.9z 1 − 0. 25δ(n) − 2.25δ(n) + 2.14) (4. √ √ y(n) − 2 2y(n − 1) + 4y(n − 2) = 4x(n) − 2 2x(n − 1) + x(n − 2) Hence for anti-causal implementation y(n) = 1 1 1 1 x(n) − √ x(n + 1) + x(n + 2) + √ y(n + 1) − y(n + 2) 4 4 2 2 ◦ ◦ 2. Imaginary Part Pole−Zero plot 1 0 −1 −1 0 1 2 Real Part Figure 4.25δ(n) − 2. The unit sample response h(n): From (4.96 e j π/4n + e j 30.16) which is an anti-causal system.25 + + .5e j 45 z −1 1 − 0. The pole-zero plot is shown in Figure 4. h i ◦ ◦ n ◦ ◦ n h(n) = 0. |z| > 2 1 − 2e j 45◦ z −1 1 − 2e− j 45◦ z −1 Hence h(n) = 0. |z| < 2 1 − 2e j 45◦ z −1 1 − 2e− j 45◦ z −1 (4.25 + + .96◦ )u(n) .96 H (z) = 0.96 2e j 45 + 2.5e− j 45 z −1   .1866e j 30.25δ(n) − 2.25 A stable.26: Problem P4. The system is anti-causal.15).1866e j 30.96 = 0.5e±45 and poles are at 2e±45 .96 2. The pole-zero plot: From (4. linear and time-invariant system is given by the following system function √ √ 4z 2 − 2 2z + 1 4 − 2 2z −1 + z −2 H (z) = √ = √ z 2 − 2 2z + 4 1 − 2 2z −1 + 4z −2   ◦ ◦ 1 − 0.1866e− j 30.25 pole-zero plot 3.16).96 2.1866(2)n e− j 30.14) above.1866e− j 30. the zeros are at 0.96 e− j π/4n u(−n − 1) = 0. |z| < 2 (for stability) = 1 − 2e j 45◦ z −1 1 − 2e− j 45◦ z −1 ◦ (4.1866(2)n cos(π n/4 − 30.96◦ )u(−n − 1) 4.Solutions Manual for DSP using Matlab (2nd Edition) 184 2006 P4.96 2e− j 45 u(−n − 1)   ◦ ◦ = 0. The causal (but not stable) unit-sample response is given by the system function ◦ ◦ 2.1866e j 30.1866(2)n cos(π n/4 − 30.15) ◦ 2.26.1866e− j 30. 1. The difference equation representation: From (4. 9801 + 12. .9801z −2 1 − 0. y(−2) = 1.17) (4.0253(0.5453 6. and steady-state responses of the system y(n) = 0. y(−1) = 0 to the input x(n) = 5(−1)n u(n): After taking the one-sided z-transform of the above difference equation.0253 5.9801 + 2z −1 = + 1 − 0.5002(0. n ≥ 0.99z 1 − 0.99)n u(n) (b) Zero-state response: From (4.5002 = + −2 −1 1 − 0.18).99)n u(n) + 5.9801 + 2z −1 −0.99z −1 Y + (z) = (4.9801 y(−2) + y(−1)z −1 + z −2 Y + (z) + X + (z) + 2 x(−1) + z −1 X + (z)   + x(−2) + x(−1)z −1 + z −2 X + (z) After substituting the initial conditions and X (z) = Z [5(−1)n u(n)] = 5 .5254(0.99z 1 − 0.5254 = + −1 1 + 0.2006 Solutions Manual for DSP using Matlab (2nd Edition) 185 P4. we obtain     Y + (z) = 0.99)n u(n) + 6.18) (4.9801z + 7z = 1 + z −1 − 0.99z −1 Hence yZS (n) = −0. we have HZI (z) = 0.9801z −2 5 + 10z −1 + 5z −2 0.9801z 1 + 0. we have HZS (z) = 5 + 10z −1 + 5z −2 −0.9801z −2   −1 −2   1 + 2z + z 5 0.9801z −2 − 0.9801 + 2z −1 = + 1 + z −1 − 0.5201(−0. zero-state.99z −1 Hence yZI (n) = −0. there is no steady-state response.0253(−0.99)n u(n) (c) Steady-state response: Since the total response y(n) goes to zero as n ր ∞.17).19) Hence y(n) = −0.9801y(n − 2) + x(n) + 2x(n − 1) + x(n − 2).99)n u(n) + 1.9801z −2 1 + z −1 1 − 0.5201 1.9801y(−2)] + [2 + x(−1)]z −1 X (z) + 1 − 0. we obtain 1 + z −1 1 + 2z −1 + z −2 + [2x(−1) + x(−2) + 0.9801z − 0.9801z −2 −1 −2 5.0253 = + −1 −2 −3 −1 1 + z − 0.9801z 1 + 0.26 The zero-input.5453(−0.9801z −2 − 0.9801z −3 −0.99z 1 − 0.99)n u(n) (a) Zero-input response: From (4.9801z −3 1 − 0. 186 Solutions Manual for DSP using Matlab (2nd Edition) 2006 . N = 8 xtilde2 = Xtilde2 = Columns 1.0000 + 0. −1.0].0. x˜1 (n) = {4. N = 5. x˜3 (n) = {1. 0}.0000i 3.0000i 5. N = 8. 0}. N = 5 xtilde3 = [1.0000 + 0.0.0000i 5. N = 6.1.0000 Columns 1. N = 3 187 0.-1.0. 2 j. Xtilde2 = dfs(xtilde2.0000 5. 0. 0.0000i 1. 0. Xtilde3 = dfs(xtilde3. −1. 2 j. 1}.0000i 2.0000i 0.6180 + 0. N = 6 xtilde4 = Xtilde4 = Columns 0 Columns 0. −1. 0.0.N) Xtilde3 = Columns 1 through 4 -1.0.-1.0000i 0.0000i 3.0.0000i 1.0.0000 2. 0.0000 + 0.N) Xtilde1 = 5.0.0000 .3820 .2j.2. 0.0].0.0000 + 0. 0}. x˜2 (n) = {2.-1. Xtilde1 = dfs(xtilde1.-1.0000 + 4.0.N) 1 through 4 3.0000i through 6 2.2.0000 + 0. 1}.0000 . x˜5 (n) = {3. x˜4 (n) = {0. 0.1 Compute the DFS coefficients of the following periodic sequences using the DFS definition and then verify your answers using Matlab . Xtilde4 = dfs(xtilde4.0000 .0000i 0.2. 0. 1.0000i 3.0000i 0.Chapter 5 The Discrete-Time Fourier Transform P5.3820 4.2j.0000 .0000 [0.0000i 3.N) 1 + 5 - through 4 4.0. 1.0000 .1]. 2.0000i -0.0000 + 0.0000 .0. −1.0000i Column 5 2.0000i 5 through 8 .0000i .0].0000i 1. N = 4 xtilde1 = [4.0.0000 [2. N = 4.6180 + 0. Xtilde5 = dfs(xtilde5.0.0000 1.2.188 Solutions Manual for DSP using Matlab (2nd Edition) xtilde5 = [3.1].N) Xtilde5 = 6. N = 3.8660i 1.5000 .8660i 2006 .5000 + 0. 0.0000i 4. X˜ 1 (k) = {4.7500 .0000 . N = 4.0000i 0 + 0.0. N = 3 Xtilde1 = [4.0.5000i 3.5000i -0. xtilde1 = idfs(Xtilde1.4.2-j*3].4000 -0. 4 j }.2500 + 0. N = 8.3804i 0. N = 5.N) xtilde5 = Columns 1 through 4 0 0.7500 . 2 − 3 j }. 3 j. −3.j*3.7500 . First use the IDFS definition and then verify your answers using Matlab .3333 -0.0.5000i 0.3804i 5.0000i 0. xtilde2 = idfs(Xtilde2. 0.7500 .0654 .0000i 0.0.2500 0. 4.N) xtilde4 = Columns 1 through 4 0. N = 4. 0. N = 3.2.0000i 0 + 0. 2 j. N = 5 Xtilde4 = [0.0.2006 Solutions Manual for DSP using Matlab (2nd Edition) 189 P5. −3 j }.5000i -0.3236 + 0. xtilde3 = idfs(Xtilde3.0000i Columns 5 through 8 0 + 0.3987 + 0.0. X˜ 5 (k) = {3.0.3236 .0.j*4]. 3 j.2351i Column 5 -0. X˜ 2 (k) = { j. 1.j*3.5000 . X˜ 4 (k) = {0.0.0. xtilde5 = idfs(Xtilde5.0. N = 4 Xtilde3 = [1.-3. 2.0.j*2.0.0000i 0.N) xtilde1 = 1.0. 0. N = 8 Xtilde5 = [3.N) xtilde3 = 2. X˜ 3 (k) = {1.0000i 3.1236 .0]. 0}. 2 + 3 j. 0}.0000i 0. xtilde4 = idfs(Xtilde4. 0.0000i 2.N) xtilde2 = 0 + 2.0.0.2+j*3.5000 .7500 .1236 + 0. 0.2 Determine the periodic sequences given the following periodic DFS coefficients.2500 -2.0]. 0.0000i .0.-j*3].2351i 0. N = 4 Xtilde2 = [j. 2.0. pha_Xtilde1(zei) = zeros(1. title(’One period of the periodic sequence xtilde_1(n)’.0.xtilde2.3).’paperunits’. [Xtilde2] = dft(xtilde2.-6.0. N2 = length(n2). title(’One period of the periodic sequence xtilde2(n)’.3.1’).3 Let x˜1 (n) be periodic with fundamental period N = 40 where one period is given by  5 sin(0.ktick.’manual’.’inches’. .’off’. Hf_2 = figure(’Units’.xtilde1.’NumberTitle’. zei = find(mag_Xtilde2 < 1000*eps). H_s1 = stem(n2.3).’paperposition’.6. 0 ≤ n ≤ 19 x˜2 (n) = 0.’XTick’.’paperposition’. 1. set(gca.’FontSize’. zei = find(mag_Xtilde1 < 1000*eps). set(gca.8).8].’fontsize’.’filled’).[0.[0. set(H_s1.ntick.3). set(H_s2.’FontSize’. ktick = [k1(1):2:k1(N1).’markersize’. set(gca. title(’Magnitude of Xtilde_1(k)’.1.3).’YTick’..[0.40)]. ’color’..N1.8) subplot(3.20)].’position’. Computation of X˜ 2 (k) using Matlab : n2 = [0:79]. Plots of x˜1 (n) and X˜ 1 (k) are shown in Figure 5.[-180.6]).0.’fontsize’.3).’filled’).1.. [Xtilde1] = dft(xtilde1.0. set(Hf_1. 20 ≤ n ≤ 39 and let x˜2 (n) be periodic with fundamental period N = 80.0.’FontSize’.[0.10).8.0.’filled’).length(zei)).1π n). set(H_s1.2). axis([-1. pha_Xtilde1 = angle(Xtilde1)*180/pi.’manual’.. H_s2 = stem(k1.200]). k1 = n1. set(gca.0. ktick = [k1(1):2:k1(N1).0.180]).[0.8]. where one period is given by  5 sin(0.1π n).’Name’.2’).’XTickMode’.N1). 0 ≤ n ≤ 19 x˜1 (n) = 0.’XTick’. zeros(1. subplot(3. ylabel(’Magnitude’).N1]’.10).’position’.mag_Xtilde1.3. ’color’.’fontsize’.1.’markersize’. subplot(3.’manual’.’normalized’.’Name’. pha_Xtilde2 = angle(Xtilde2)*180/pi. xtilde2 = [xtilde1.zeros(1.’XTickMode’.N1.-90.6.1*pi*[0:19]).0]. xtilde1 = [5*sin(0.8).’normalized’.’inches’. k2 = n2. xlabel(’k’). mag_Xtilde2 = abs(Xtilde2).ktick.’XTick’.N1]’.’P5.’markersize’. set(Hf_2.-200. mag_Xtilde1 = abs(Xtilde1).’XTickMode’.’off’.’P5.5]).N2). ntick = [n1(1):2:n1(N1). title(’Phase of Xtilde_1(k)’.’YTickMode’..0. axis([-1.length(zei)). set(H_s3.0.0. Computation of X˜ 1 (k) using Matlab : n1 = [0:39].1.10).190 Solutions Manual for DSP using Matlab (2nd Edition) 2006 P5.1.1).pha_Xtilde1.90..’fontsize’.1.’filled’).1.1.N1.max(mag_Xtilde1)+10]).8. H_s3 = stem(k1.1.’manual’. Hf_1 = figure(’Units’.10).5]).1). H_s1 = stem(n1. 20 ≤ n ≤ 79 These two periodic sequences differ in their periodicity but otherwise have the same non-zero samples. axis([-1. subplot(3.0].N1]’.’markersize’.’NumberTitle’. ylabel(’Degrees’).[0. ylabel(’Amplitude’).’paperunits’. N1 = length(n1). pha_Xtilde2(zei) = zeros(1. ylabel(’xtilde2’).’XTickMode’.3a ntick = [n2(1):5:n2(N2). set(H_s2.pha_Xtilde2.’YTickMode’. H_s3 = stem(k2. set(H_s3.3).180]) Plots of x˜2 (n) and X˜ 2 (k) are shown in Figure 5.ntick) subplot(3.N2]’. set(gca.’XTick’. axis([-1. ylabel(’Degrees’) ktick = [k2(1):5:k2(N2).0.’manual’.’XTick’. in (5) ω1 = π/20 and in (5) ω2 = π/40.’manual’.10). H_s2 = stem(k2.’filled’).e.N2. title(’Phase of Xtilde2(k)’.’manual’. xlabel(’k’). set(gca.1: Plots of x˜1 (n) and X˜ 1 (k) in Problem 5.N2]’. . axis([-1.-200.3).N2.2).’filled’).-6..10).’XTickMode’.’YTick’.’XTickMode’.’fontsize’. The shape of the DTFT begins to fill in with N = 80.[-180.’markersize’.90.’markersize’. axis([-1.ktick) set(gca. Changing the period from N = 40 to N = 80 resulted in a lower frequency sampling interval (higher frequency resolution) ω1 . i.2006 Solutions Manual for DSP using Matlab (2nd Edition) 191 One period of the periodic sequence xtilde1(n) Amplitude 5 0 −5 0 2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 40 26 28 30 32 34 36 38 40 26 28 30 32 34 36 38 40 Magnitude of Xtilde1(k) Magnitude 60 40 20 0 0 2 4 6 8 10 12 14 16 18 20 22 24 Phase of Xtilde1(k) Degrees 180 90 0 −90 −180 0 2 4 6 8 10 12 14 16 18 20 k 22 24 Figure 5. title(’Magnitude of Xtilde2(k)’.ktick) subplot(3.1.1.2.60]).3).-90. set(gca.’manual’.’fontsize’. Hence there are more terms in the DFS expansion of x˜2 (n).N2.6]).200]).0.mag_Xtilde2.’XTick’. 3. ylabel(’|Xtilde2|’) ktick = [k2(1):5:k2(N2).N2]’. Solutions Manual for DSP using Matlab (2nd Edition) 192 2006 One period of the periodic sequence xtilde2(n) xtilde2 5 0 −5 0 5 10 15 20 25 30 35 40 45 50 55 60 65 70 75 80 55 60 65 70 75 80 55 60 65 70 75 80 Magnitude of Xtilde2(k) |Xtilde2| 60 40 20 0 0 5 10 15 20 25 30 35 40 45 50 Phase of Xtilde2(k) Degrees 180 90 0 −90 −180 0 5 10 15 20 25 30 35 40 k 45 50 Figure 5.2: Plots of Magnitude and Phase of X˜ 2 (k) in Problem 5.3b . -xtilde1]. mag_Xtilde2 = abs(Xtilde2).’fontsize’.2’). Let x˜2 (n) be periodic with fundamental period N = 40.’fontsize’.10).mag_Xtilde2. set(gca.N2.0.1). k2 = n2. pha_Xtilde2 = angle(Xtilde2)*180/pi.4 Consider the periodic sequence x˜1 (n) given in Problem 5.’P5.length(zei)).. [Xtilde2] = dft(xtilde2.’markersize’. 2. ’color’.’YTick’.200]).0.1. H_s2 = stem(k2.10).10).’inches’.4]). where one period is given by  x˜1 (n).1.ktick) set(gca. set(H_s2.’XTick’.ktick) subplot(3. set(H_s3. title(’One period of the periodic sequence xtilde_2(n)’.0].’manual’.N2.-6.3.N2]’. set(gca.1*pi*n1)].ntick) subplot(3.[-180.0.8].N2]’. ylabel(’Amplitude’). Computation of the DFS X˜ 2 (k) using Matlab : n1 = [0:19]. title(’Phase of Xtilde2(k)’.’manual’. xlabel(’k’).’paperunits’.3).’filled’).-90. Determine analytically the DFS X˜ 2 (k) in terms of X˜ 1 (k). axis([-1.100]). n2 = [0:39].8.6. H_s1 = stem(n2.’XTick’. set(H_s1. 20 ≤ n ≤ 39 1.’NumberTitle’.. axis([-1.’YTickMode’.N2).’markersize’.0.1.3)..2006 Solutions Manual for DSP using Matlab (2nd Edition) 193 P5.pha_Xtilde2.N2.’position’.[0. H_s3 = stem(k2.3). ntick = [n2(1):5:n2(N2).’XTickMode’.’filled’).N2]’.6]).-200.’filled’). axis([-1. title(’Magnitude of Xtilde2(k)’.’Name’. xtilde1 = [5*sin(0.’normalized’.2).0. ylabel(’Degrees’) ktick = [k2(1):5:k2(N2).’manual’.’manual’. subplot(3.xtilde2. xtilde2 = [xtilde1.180]) Plots of x˜2 (n) and X˜ 2 (k) are shown in Figure 5. Hf_1 = figure(’Units’.[0.4.3).0. Verify your answer in part 1 above using the plots of X˜ 1 (k) and X˜ 2 (k)? . pha_Xtilde2(zei) = zeros(1.’off’.’XTickMode’. N2 = length(n2). ylabel(’Magnitude’) ktick = [k2(1):5:k2(N2).’XTick’.’markersize’.1.1. 3. 0 ≤ n ≤ 19 x˜2 (n) = −x˜1 (n − 20). set(gca.0. set(Hf_1.’paperposition’.[0.’fontsize’. zei = find(mag_Xtilde2 < 1000*eps).’XTickMode’.90.3. 4b .3: Plots of Magnitude and Phase of X˜ 2 (k) in Problem 5.Solutions Manual for DSP using Matlab (2nd Edition) 194 2006 One period of the periodic sequence xtilde2(n) Amplitude 5 0 −5 0 5 10 15 20 25 30 35 40 25 30 35 40 25 30 35 40 Magnitude of Xtilde2(k) Magnitude 100 50 0 0 5 10 15 20 Phase of Xtilde2(k) Degrees 180 90 0 −90 −180 0 5 10 15 20 k Figure 5. Hf_1 = figure(’Units’.180]) Plots of x˜3 (n) and X˜ 3 (k) are shown in Figure 5.N3.’manual’. .0.’YTick’.3). obtained by concatenating two periods of x˜1 (n).2006 Solutions Manual for DSP using Matlab (2nd Edition) 195 P5.-180. Comparing the magnitude plot above with that of X˜ 1 (k) in Problem (5).3. N − 1 0 .max(mag_Xtilde3)]).’normalized’.axis([-1.0. .6]). (In general.5 Consider the periodic sequence x˜1 (n) given in Problem 5. .N3]’.’markersize’. x˜1 (n) PERIODIC Clearly. xtilde3 = [xtilde1. Clearly these phase values have no meaning and should be ignored. set(gca.’P5..N3]’. X˜ M (Mk) = M X˜ 1 (k) .e.’XTick’. set(H_s3.90. 1. we do get non-zero phase values when the magnitudes are zero. N3 = length(n3). axis([-1.’XTickMode’. i. Computation and plot of the DFS X˜ 3 (k) using Matlab : n1 = [0:39].length(zei)). zei = find(mag_Xtilde3 < 0.0.’markersize’.zeros(1. set(gca.8]. We can now generalize this argument. title(’Phase of Xtilde3(k)’. xlabel(’k’).) This makes sense because sequences x˜1 (n) and x˜3 (n). .’manual’. x˜3 (n) is different from x˜2 (n) of Problem 5.0. when viewed over −∞ < n < ∞ interval. ’color’.0.[-180. ylabel(’Amplitude’).3 even though both of them are periodic with period 80.3). .. This happens because of a particular algorithm used by Matlab.180]).0].3). H_s3 = stem(k3. pha_Xtilde3 = angle(Xtilde3)*180/pi.pha_Xtilde3.8) subplot(3. x˜1 (n) {z } | M times PERIODIC then there will be (M − 1) zeros between samples of X˜ M (k).ktick) subplot(3. pha_Xtilde3(zei) = zeros(1.20)]. M N X˜ M (k) = .00001). k = 0. mag_Xtilde3 = abs(Xtilde3). xtilde1 = [5*sin(0.’filled’).-90.N3. title(’One period of the periodic sequence xtilde_3(n)’.   x˜3 (n) = x˜1 (n). The magnitudes of non-zero samples of X˜ M (k) will be M times the magnitudes of the samples of X˜ 1 (k). for phase plots. H_s1 = stem(n3. x˜1 (n) .’Name’.’fontsize’. .1).’paperunits’. The effect of periodicity doubling is in the doubling of magnitude of each sample.1’).N3).10). Let x˜3 (n) be periodic with period 80. . We avoided this problem by using the find function.’XTick’.. set(Hf_1.’fontsize’.’YTickMode’. . . set(gca.5.1.3).[0. n3 = [0:79]. ylabel(’Magnitude’) ktick = [k3(1):5:k3(N3).8.’markersize’.1. Plots of X˜ 3 (k) have one zero between every sample of X˜ 1 (k). . ktick = [k3(1):5:k3(N3).’fontsize’. k3 = n3.6. title(’Magnitude of Xtilde_3(k)’.N3]’.1.’position’.xtilde3..’off’.axis([-1.’NumberTitle’. H_s2 = stem(k3..’XTickMode’.2). ntick = [n3(1):5:n3(N3).’inches’.’filled’). 2.’manual’.e.ktick) set(gca.’fontsize’. i.[0.ntick.mag_Xtilde3. subplot(3. set(H_s1. 1.1.’manual’. 1. ylabel(’Degrees’).1*pi*[0:19]).5]).N3.4.10). look exactly same. set(H_s2.’XTick’. . k 6 = 0.’filled’).0.1. we observe that these plots are essentially similar. If     x˜ M (n) = x˜1 (n) . . 1.[0.’paperposition’.min(mag_Xtilde3).’XTickMode’.10). [Xtilde3] = dft(xtilde3. xtilde1].-6. Solutions Manual for DSP using Matlab (2nd Edition) 196 2006 One period of the periodic sequence xtilde3(n) Amplitude 5 0 −5 0 5 10 15 20 25 30 35 40 45 50 55 60 65 70 75 80 55 60 65 70 75 80 55 60 65 70 75 80 Magnitude of Xtilde3(k) Magnitude 100 50 0 0 5 10 15 20 25 30 35 40 45 50 Phase of Xtilde3(k) Degrees 180 90 0 −90 −180 0 5 10 15 20 25 30 35 40 k 45 50 Figure 5.5a .4: Plots of x˜3 (n) and X˜ 3 (k) in Problem 5. 255}periodic Matlab verification: n = 0:99. 0. Let 200-point   y2 (n) = IDFS X (e j 0 ). 3.100-n(51:100)]. 0 ≤ n ≤ 49. X (e j 2π/200).  n + 1. w1 = 2*pi*k1/N1. . X (e j 18π/10)  which is a 10-point IDFS of ten samples of X e j ω on the unit circle. X (e j 2π/10 ). .w2). . 50 ≤ n ≤ 100. . Y1 = dtft(x. . X (e j 4π/200 ). 2 + 12 + · · · + 42 + 49 + · · · + 9. . x = [n(1:50)+1. Let 10-point   y1 (n) = IDFS X (e j 0 ).N1)).n. Thus y1 (n) = ∞ X r=−∞ x(n − 10r) = {1 + 11 + · · · + 41 + 50 + 40 + · · · + 10.n.w1). .100-n(51:100)]. 1. . 50 ≤ n ≤ 99. otherwise. N2 = 200. Y2 = dtft(x. N1 = 10.N2)). .  periodic Matlab verification: n = 0:99. . 2.2006 Solutions Manual for DSP using Matlab (2nd Edition) 197 P5. y2 = real(idfs(Y2. . w2 = 2*pi*k2/N2. . · · · }periodic = {255. See the stem plot of y1 (n) in Figure 5. X (e j 4π/10 ). y1 = real(idfs(Y1. Thus y2 (n) =  x(n). 255. X (e j 398π/200)  which is a 200-point IDFS of 200 samples of X e j ω on the unit circle.6 Let X (e j ω ) be the DTFT of a finite-length sequence  0 ≤ n ≤ 49. . k2 = 0:N2-1. See the stem plot of y1 (n) in Figure 5. x = [n(1:50)+1.5. . k1 = 0:N1-1. x(n) = 100 − n.  0.5. The sequence y1 (n) is a 10-point aliasing version on x(n) while y2 (n) is a zero-padded version of x(n). Solutions Manual for DSP using Matlab (2nd Edition) 198 2006 Amplitude Original 100−point sequence x(n) 40 20 0 0 10 20 30 40 50 60 70 80 90 100 Aliased sequence y1(n) Amplitude 300 200 100 0 0 1 2 3 4 5 6 7 8 9 10 11 Unaliased sequence y2(n) Amplitude 50 40 30 20 10 0 −1 49 99 n 149 Figure 5.6 199 .5: Plots of y1 (n) and y2 (k) in Problem 5. fliplr(x_tilde(2:end))].7321i (c) Computation of Y˜ (k) for 0 ≤ k ≤ 5: y_tilde = Y_tilde = Y_tilde = Columns 21.0000 .0000 + 3.1. 1.0000 .N) 1 through 4 1.N) X_tilde = Columns 1 through 4 21. 1.fliplr(X_tilde(2:end))]. 6.7321i -6.0000 -6.0000 + 1. 5}PERIODIC with N = 6.W_tilde)) error = 2.4641i 1.1.0000 .3.5434e-014 1.0000 1. ↑ (a) Sketch of y˜ (n) for 0 ≤ n ≤ 5: One period of the periodic sequence xtilde(n) 7 Amplitude 6 5 4 3 2 1 0 0 1 2 3 4 5 n ˜ (b) Computation of X(k) for 0 ≤ k ≤ 5: X_tilde = dft(x_tilde.0000i [x_tilde(1). Let x(n) ˜ = {2.0000 Columns -6.0000 + 0. dft(y_tilde.0000 + 1. ˜ Let X˜ (k) and Y˜ (k) be the DFS sequences.4641i 1. 3.4641i 1. Consider N−1 N−1 N−1 X X   X nk nk ˜ Y (k) = DFS y˜ (n) = y˜ (n)W N = x(−n)W ˜ x(N ˜ − n)W Nnk N = n=0 = N X ℓ=1 (N−ℓ)k x(ℓ)W ˜ = N n=0 N−1 X ℓ=0 n=0 −ℓk Nk x(ℓ)W ˜ = N WN ˜ = X˜ (−k) = X(N − k) N−1 X ℓ=0 −ℓk x(ℓ)W ˜ N (∵ periodic) 2.3.7321i Columns 5 through 6 -6.7 Let x(n) ˜ be a periodic sequence with period N and let △ y˜ (n) = x(−n) ˜ = x(N ˜ − n) that is.0000 . error = max(abs(Y_tilde .0000 .0000i .2006 Solutions Manual for DSP using Matlab (2nd Edition) 199 P5. y˜ (n) is a periodically folded version of x(n).7321i (d) Matlab verification: W_tilde = [X_tilde(1).4641i 5 through 6 + 3. 4.0. subplot(2.1. % % % % % given signal x(n) DFT of x(n) Mag and Phase of X(k) Set phase values to zero when mag is zero Hf_1 = figure(’Units’. N = length(xn). hold on subplot(2.0. plot(w/Dw.1).8 Consider the finite-length sequence given below.[0.pha_X). grid hold off  The continuous plot of X e j ω is also shown in Figure 5.6. xn = sinc((n-50)/2).[0.90. DTFT X e j ω : [X. is the sampled version of X e j ω .’position’.’whole’). It is possible to reconstruct the DTFT from the DFT if length of the DFT is larger than or equal to the length of sequence x (n).5:2. Xk = dft(xn.8.2).10). where X (k) e− j (50)ω φ (ω) = e− j ω(N−1)/2 sin (50.w] = freqz(xn. the DFT in part 1. title(’Magnitude plots of DFT and DTFT’. ’color’.8).5ω) 101 sin (ω/2) sin (ωN/2) N sin (ω/2) . else.  sinc2 {(n − 50)/2}.’YTick’.0].180].2).’markersize’.^2. ylabel(’Degrees’).200]) set(gca. DFT X (k): n = 0:100.  2.1.[0:20:N].-90.mag_Xk.N.’fontsize’. hold on The stem plot of X (k) is shown in 5.0.[0..’XTick’. Dw = (2*pi)/N. zei = find(mag_Xk < 0.’paperposition’.0.pha_Xk.5]) set(gca.’NumberTitle’.Solutions Manual for DSP using Matlab (2nd Edition) 200 2006 P5.’fontsize’.’filled’).length(zei)).1.10). We can reconstruct using the complex interpolation formula X e jω  = N−1 X k=0  2π k X (k) φ ω − N For N = 101. xlabel(’k’). axis([0.8).1.’P5. plot(w/Dw.[0:20:N].[0:0. grid hold off subplot(2.0. mag_Xk = abs(Xk). we have X e jω  = 100 X k=0  . set(H_s2. 0 ≤ n ≤ 100.5]). subplot(2.00001).[-180.N.8]..N). H_s1 = stem(k. 1.3).-200.’YTick’. Clearly.5]. H_s2 = stem(k.’markersize’.8’).’Name’. pha_X = angle(X)*180/pi.’filled’).2. x(n) = 0. ylabel(’Magnitude’).’fontsize’.0. axis([0.8). % DTFT of xn % mag and phase of DTFT % frequency resolution  3. set(gca.3).1000.1.6.8).1.’inches’.’fontsize’. pha_Xk(zei) = zeros(1. title(’Phase plots of DFT and DTFT’. pha_Xk = angle(Xk)*180/pi.’normalized’.’fontsize’. 4.0.mag_X).’off’.6.1.1). set(Hf_1. mag_X = abs(X).. set(gca.’fontsize’. set(H_s1.’XTick’. k = 0:N-1.0.’paperunits’. 5 0 0 20 40 60 80 100 80 100 Phase plots of DFT and DTFT 180 Degrees 90 0 −90 −180 0 20 40 60 k Figure 5.6: Plots of DTFT and DFT of signal in Problem 5.8 .2006 Solutions Manual for DSP using Matlab (2nd Edition) 201 Magnitude plots of DFT and DTFT 2.5 1 0.5 Magnitude 2 1. 10). Matlab script: clc.’paperposition’.[0.0. Hf_1 = figure(’Units’.. Xk = dft(xn.’inches’.7: Plots of DTFT and DFT of signal in Problem 5.1.6 −0.3]). plot(w/pi. plot([-1.’off’.5]. hold on.2 0 ω/π 0.0.0].Xk.5]).1.9*abs(n)). xn = [xn.’position’.N-N1)].’Name’. x(n) = 0.7.’fontsize’. axis([-1.0.5).-4..6. otherwise.0]. close all.9|n| 2e .N).1. xlabel(’\omega/\pi’.Solutions Manual for DSP using Matlab (2nd Edition) 202 2006 P5.9 The DTFT X (e j ω ) of the following finite-length sequence using DFT as a computation tool  −0.zeros(1. DTFT of x(n) = 2e−0.5).10).8]..1.6 Figure 5.[-4. N1 = length(xn). ’color’.9 0.N).’normalized’.9’). Xk = fftshift(Xk).’w’.’fontsize’.0.[0.’paperunits’.pi.4 0. −5≤ n≤ 5 5 4 3 Amplitude 2 1 0 −1 −2 −3 −4 −1 −0. N = 201.9|n|.’linewidth’. xn = 2*exp(-0.8.’w’.’fontsize’. −5 ≤ n ≤ 5.[0.4 −0. set(Hf_1.’g’.2 0. ylabel(’Amplitude’.0].’NumberTitle’.8 1 .0.’linewidth’. w = linspace(-pi.9|n|}.0.10). -5\leq n\leq 5’.[0.8 −0.’P5. n = -5:5. title(’DTFT of x(n) = 2e^{-0.[0.1]. Xk = real(Xk). The plot of the DTFT X (e j ω ) is shown in 5. 6 0.’off’.1).’paperunits’.[1. subplot(2..11]). % Length of DFT x1 = [x1(11:end).’paperposition’. axis([0.[0. subplot(2.’inches’. print -deps2 .6. Magnitude of DTFT X (ejω) 1 5 Magnitude 4 3 2 1 0 0 0.4].3 0.6 Figure 5.200]).0. % Assemble x1 [X1] = fft(x1.4]).’inches’.’position’.10. axis([0.2 0..4 0.6). x1(1:10)].8: Plots of DTFT magnitude and phase in Problem 5. w = (0:N/2)*2*pi/N. Hf_1 = figure(’Units’.1 .10.7 0. N = 200.^abs(n1).8 0.0].1.[0. ylabel(’Magnitude’).3 0.10 Plot of the DTFT magnitude and angle of each of the following sequences using the DFT as a computation tool.0. Matlab script: n1 = [-10:10].2).1. ’color’.’linewidth’.1).8.-200.4 0.8 0.9 1 0.2006 Solutions Manual for DSP using Matlab (2nd Edition) 203 P5. mag_X1 = abs(X1(1:N/2+1)).5 ω/π 0.6)|n| [u(n + 10) − u(n − 10)]. title(’Angle of DTFT X_1(e^{j\omega})’).’g’. zeros(1.. N1 = length(n1).’linewidth’.’P5.1.pha_X1.7 0. plot(w/pi.’NumberTitle’..2 0. xlabel(’\omega/\pi’).6. plot(w/pi./EPSFILES/P0510a The plot of the DTFT X 1 (e j ω ) is shown in 5.1. ylabel(’Degrees’). x1 (n) = (0.9 1 Angle of DTFT X1(ejω) 200 Degrees 100 0 −100 −200 0 0.’Name’.’g’. x1 = (0.mag_X1. pha_X1 = angle(X1(1:N/2+1))*180/pi. title(’Magnitude of DTFT X_1(e^{j\omega})’).1’).0.N). 1.1 0.1.1 0.1).N-N1). set(Hf_1.5 0. ’off’.1.*(0.N)../EPSFILES/P0510b The plot of the DTFT X 2 (e j ω ) is shown in 5.’paperposition’.3 0. % Assemble x2 [X2] = fft(x2.’g’.^n2.9)n .’P5.0. plot(w/pi.’paperunits’.6 0.200]). Hf_2 = figure(’Units’.1 0.[0. x2 = n2.mag_X2.9 1 Angle of DTFT X2(ejω) 200 Degrees 100 0 −100 −200 0 0.3 0.5]).5 ω/π 0. ylabel(’Degrees’). title(’Angle of DTFT X_2(e^{j\omega})’).7 0. 0 ≤ n ≤ 20.1).1).2 . title(’Magnitude of DTFT X_2(e^{j\omega})’).4]. %axis([0. N2 = length(n2).1 0..’linewidth’.5 0. % Length of DFT x2 = [x2.6. subplot(2.1). mag_X2 = abs(X2(1:N/2+1)).4 0.pha_X2.’NumberTitle’. subplot(2.1. Matlab script: n2 = [0:20]. ylabel(’Magnitude’).4 0.Solutions Manual for DSP using Matlab (2nd Edition) 204 2006 2. w = (0:N/2)*2*pi/N.’inches’.’Name’. N = 400..zeros(1. axis([0.1.N-N2)].9.2’).-200.9). set(Hf_2.0.[1.’position’.10.8 0.0]. pha_X2 = angle(X2(1:N/2+1))*180/pi.’linewidth’..[0.’g’.7 0.2 0. xlabel(’\omega/\pi’). print -deps2 .9: Plots of DTFT magnitude and phase in Problem 5.2 0. ’color’.’inches’.10.6.1. Magnitude of DTFT X (ejω) 2 Magnitude 60 40 20 0 0 0.4]).9 1 0.6 Figure 5. plot(w/pi.2). x2 (n) = n(0.1.0.8 0. x3 (n) = cos(0.9 1 Angle of DTFT X3(ejω) 200 Degrees 100 0 −100 −200 0 0.0.’inches’.7 0.4]).9 1 0. w = (0:N/2)*2*pi/N. N = 500. subplot(2.1. plot(w/pi. plot(w/pi.. xlabel(’\omega/\pi’)./EPSFILES/P0510c The plot of the DTFT X 3 (e j ω ) is shown in 5.-200. axis([0. subplot(2.1.’linewidth’. % Assemble x3 [X3] = dft(x3.[0.8 0.’inches’. 0 ≤ n ≤ 50.10.6.4].6 Figure 5.2 0.8 0.[1. title(’Magnitude of DTFT X_3(e^{j\omega})’).0.mag_X3.zeros(1.5 0.4 0..3 0.6 0.’position’. Matlab script: n3 = [0:50].7 0. x3 = [x3. title(’Angle of DTFT X_3(e^{j\omega})’).1. pha_X3 = angle(X3(1:N/2+1))*180/pi.’paperposition’.2 0.N-N3)].. mag_X3 = abs(X3(1:N/2+1)).’g’. %axis([0.1.1.2).% Length of DFT N3 = length(n3).3’).’g’.5π n).10: Plots of DTFT magnitude and phase in Problem 5.’linewidth’. set(Hf_3.3 0. ylabel(’Degrees’).2006 Solutions Manual for DSP using Matlab (2nd Edition) 205 3.4 0..200]).0].10.pha_X3.5 ω/π 0.5*pi*n3)+j*sin(0.1).6.1 0.’paperunits’. Magnitude of DTFT X (ejω) 3 Magnitude 60 40 20 0 0 0. x3 = cos(0. ’color’.1 0. print -deps2 .5π n) + j sin(0.’Name’.1). Hf_3 = figure(’Units’.10.N).7000]).3 .5*pi*n3).’NumberTitle’.[0.0. ylabel(’Magnitude’).’P5.’off’.1). Magnitude of DTFT X4(ejω) Magnitude 20 15 10 5 0 0 0.’inches’.4’). N = 100.-200.N-N4)].1.4 0.1).[0.[1.2.2). subplot(2. set(Hf_4.pha_X4.8 0.N).1 0.6.3.1.0].4 0. pha_X4 = angle(X4(1:N/2+1))*180/pi.6 Figure 5. print -deps2 .200]).’P5.1. plot(w/pi. 4.9 1 0. title(’Magnitude of DTFT X_4(e^{j\omega})’). ylabel(’Magnitude’).’g’.1]. zeros(1.5 ω/π 0.3.’linewidth’.’NumberTitle’. 2.11: Plots of DTFT magnitude and phase in Problem 5.10.4 . 3. N4 = length(n4). % Length of DFT [X4] = dft([x4.6..’paperunits’.3 0. axis([0.1.1).’linewidth’. axis([0. 2.’Name’. w = (0:N/2)*2*pi/N.5 0.11.3 0.0..0.9 1 jω Angle of DTFT X4(e ) 200 Degrees 100 0 −100 −200 0 0. plot(w/pi.’position’.2. 1}.7 0.2 0.10.’off’.20]). title(’Angle of DTFT X_4(e^{j\omega})’). 3.8 0.1 0.4.’g’. x4 = [1.Solutions Manual for DSP using Matlab (2nd Edition) 206 2006 4.[0. x(n) = {1.4]).7 0.4].2 0..’paperposition’. xlabel(’\omega/\pi’).6 0.mag_X4../EPSFILES/P0510d The plot of the DTFT X 4 (e j ω ) is shown in 5.’inches’. ylabel(’Degrees’). Matlab script: ↑ n4 = [-3:3]. ’color’.0.1). Hf_4 = figure(’Units’.1. mag_X4 = abs(X4(1:N/2+1)). subplot(2. 1.’off’.5 0. plot(w/pi. plot(w/pi.-3.1).1../EPSFILES/P0510e The plot of the DTFT X 5 (e j ω ) is shown in 5.1.[0.9 1 jω Angle of DTFT X5(e ) 200 Degrees 100 0 −100 −200 0 0.5 .[0.7 0.1].2). −3.6 Figure 5.1 0. subplot(2.10.pha_X5. ylabel(’Magnitude’).N).5 ω/π 0.1. axis([0. 3.’linewidth’.1). ylabel(’Degrees’). Hf_5 = figure(’Units’. Magnitude of DTFT X5(ejω) Magnitude 20 15 10 5 0 0 0.’position’.3 0.-2.’g’.-200. % Length of DFT [X5] = dft([x5.12.N-N5)]. −2. 1}.0.6. x(n) = {−1.8 0.’inches’.4 0. set(Hf_5.3 0.’paperunits’.2. w = (0:N/2)*2*pi/N.’inches’.’paperposition’.12: Plots of DTFT magnitude and phase in Problem 5. N5 = length(n5).1.7 0..mag_X5. title(’Angle of DTFT X_5(e^{j\omega})’).’linewidth’.9 1 0. 2..’g’.3.20]).’Name’. mag_X5 = abs(X5(1:N/2+1)). print -deps2 .0. subplot(2.4].2006 Solutions Manual for DSP using Matlab (2nd Edition) 207 5. title(’Magnitude of DTFT X_5(e^{j\omega})’).4]).8 0. xlabel(’\omega/\pi’).5’).[1.2 0.1 0.6 0. N = 100.10.0. pha_X5 = angle(X5(1:N/2+1))*180/pi.. x5 = [-1. Matlab script: ↑ n5 = [-3:3].1).’P5.200]).0].’NumberTitle’. 0. ’color’.0.4 0. axis([0. zeros(1.2 0.6. 9. error = max(abs(Hr-Hr_check)) error = 4.zeros(1. Hi_check = 2*l*sin(l’*w(1:end-1)). else Matlab verification: n = 0:5.8014e-013 . h = (0. 0 ≤ n ≤ 5 h(n) = 0.9)n . Hr = real(H). error = max(abs(Hi-Hi_check)) error = 3.0856e-014   P Rπ  2. else Matlab verification: n = 0:5. we obtain  (0.N+1). h = -2*n. H = dft(h. It is known that Im H e j ω = 5ℓ=0 2ℓ sin ωℓ and −π H e j ω dω = 0.N-N1)]. w = linspace(0. N = 100.N).11 Let H (e j ω ) be the frequency response of a real.Solutions Manual for DSP using Matlab (2nd Edition) 208 2006 P5. h = [h. N = 100. k = [0:5]. w = linspace(0. It is known that Re H e j ω = 5k=0 (0.2*pi.^n. Consider (∞ ) ∞ ∞ X X  X   Re H e j ω = Re h(k)e− j ωk = h(k) Re e− j ωk = h(k) cos ωk k=0 k=0 k=0 Comparing with the given expression. Hi = imag(H).N-N1)]. H = dft(h. l = [0:5]. causal impulse response h(n).   P 1. Hr_check = (0. From the second condition Z π −π Consider  Im H e jω  = Im ( ∞ X ℓ=0  H e j ω dω = h (0) = 0 h(ℓ)e − j ωℓ ) = ∞ X ℓ=0 ∞ X  h (ℓ) Im e− j ωℓ = − h (ℓ) sin ωℓ ℓ=0 Comparing with the given expression.N+1). N1 = length(h). we obtain  −2n.2*pi. 0 ≤ n ≤ 5 h(n) = 0. N1 = length(h).9).^k)*cos(k’*w(1:end-1)).9)k cos ωk. h = [h.N).zeros(1. 2006 Solutions Manual for DSP using Matlab (2nd Edition) 209 P5. if a given DFT function is working correctly then four successive applications of this function on any arbitrary signal will produce the same signal (multiplied by N 2 ).N) Y = 1.000 5.-1].N) % Circular folding with respect to N % ---------------------------------% function x2 = circfold(x1. Continuing further.000 7.-7.000 -1. 0 ≤ n ≤ N − 1 N δ (m + n − r N ) .3. 0 ≤ n ≤ N − 1 x (−n + r N ) = N x ((−n)) N . Matlab verification: x = [1.000 -3. 0 ≤ n ≤ N − 1 This means that y (n) is a “circularly folded and amplified (by N )” version of x (n).9.5. ( N−1 N−1 X X y (n) = k=0 x (m) m=0 = N m=0 (m) W Nmk m=0 N−1 X = x N−1 P ∞ X r=−∞ N−1 X k=0 x (m) W Nmk .N) % x2(n) = x1((-n) mod N) % x2 = real(dft(dft(x1. W Nmk W Nkn .N))/N. x = 1 3 5 7 9 -7 -5 -3 -1 Y = circfold(x.000 -5.000 .-3.000 -7. 1. 3. 2. Matlab function for circular folding: function x2 = circfold(x1.N). N = length(x). if we take two more DFTs of x (n) then x (n) −→ N -point DFT −→ N -point DFT N -point DFT −→ −→ N -point DFT −→ N 2 x (n) Therefore. The N -point DFT of X (k): y (n) = ) W Nkn = W N(m+n)k = N−1 X N−1 X x (m) m=0 N−1 X k=0 x (m) ∞ X r=−∞ m=0 N−1 P k=0 X (k) W Nkn .000 9. The N -point DFT of x (n): X (k) = Hence.000 3.12 Let X (k) denote the N -point DFT of an N -point sequence x(n). The DFT X (k) itself is an N -point sequence.-5. This approach can be used to verify a DFT function.7. 7082 -13.0000 + 0. x = [1.0000i 15. X = dft(x.9353i 0.0000 + 0.-3.0000i 4.3.0000 -8.0000i 0.0000 + 0.1803 -10.7082 + 9. Non-zero.5].0000i .0000 . Given that x(n) = x(n + N/2) for all n.0000i -0. 2. Non-zero. 5.-1.4. 4. 1.N) X = 0 -7. Given that x(n) = −x(n + N/2) for all n. 4. k odd.5.0. Verification using x(n) = {1. 2.9353i -8.0. 3.0000i 2.0. Verification using x(n) = {1. 4. 2.1803 +10.-3.0000i -7.-2. −5}. −2.4.1392i -0. k even. X = dft(x.7082 +13. k even.0. X = 18.1392i 0.13 Let X (k) be an N -point DFT of an N -point sequence x(n).-5].1. consider X (k) = N−1 X n=0 N/2−1 X x(n)W Nnk = n=0 N/2−1 = x(n)W Nnk + X x(n)W Nnk + X  x(n) 1 + (−1)k W Nnk N/2−1 = n=0 n=0 x(n + N/2)W N X x(n)W Nnk W N (n+N/2)k [∵ n → n + N/2] N/2−1 N/2−1 = X n=0 x(n)W Nnk n=N/2 N/2−1 X n=0 N−1 X x(n)W Nnk + Nk/2 [∵ x(n) = x(n + N/2)] n=0 [∵ N/2 WN = −1] =  0.2.1803 -12.9.N) + 0.2.0000 N = length(x). 5.7082 .7881i 0. −3. −3. consider X (k) = N−1 X N/2−1 x(n)W Nnk n=0 = N/2−1 = = n=0 X x(n)W Nnk + X x(n)W Nnk X  x(n) 1 − (−1)k W Nnk n=0 n=0 N/2−1 = x(n)W Nnk N/2−1 N/2−1 = X n=0  X n=0 + N−1 X x(n)W Nnk n=N/2 (n+N/2)k x(n + N/2)W N [∵ n → n + N/2] N/2−1 − X Nk/2 x(n)W Nnk W N n=0 N/2 [∵ W N [∵ x(n) = −x(n + N/2)] = −1] 0.210 Solutions Manual for DSP using Matlab (2nd Edition) 2006 P5. 5}: x = [1.7881i -0.1803 +12.1311i .0.0000i -6. −1.0000i .0000 . 1.0.0000 4. N = length(x).2.0000 .1311i -0.0000i 15. k odd. −3.-4.5.-3. −4.0000 -0.0000 . Let N be an even integer.4. 2. 1.-3]. 3. Verification for x(n) = {1.0000i -0. Let n = m + pν.0000i 0.0000i 0.0000 - N = length(x).0.0000i ] .0000i -0.0000i 2.2.4641i 0. −1. 0 ≤ p ≤ 3.0000 + 0. 0. It is given that x(n) = −x(n + ν) for all n.3. X = dft(x.3.0000 -0. 2.3. X = 24. X = dft(x.0000 .-2.-3. 3.0000 .0.2)] 0. −2. 0. k = 4ℓ for 0 ≤ ℓ ≤ ν − 1. 2.-1.0000 0 0 2.1. 0 ≤ p ≤ 3. −3.3.3. 2.14 Let X (k) be an N -point DFT of an N -point sequence x(n).0000 .0000 -6. N = X = 0 0 2.N) 0.2. then x(n) = −x(n + ν) ⇒ x(m + pν) = (−1) p x(m).2. 0 ≤ m ≤ ν − 1. x = [1. 3.0000 .0000 [∵ (5.0000i -0.0000 0 0 8. −3}.0000 + 0. then x(n) = x(n + ν) ⇒ x(m + pν) = x(m). 0 ≤ m ≤ ν − 1. 1. 0 ≤ m ≤ ν − 1. 2. It is given that x(n) = x(n + ν) for all n.0.1.0000 .2006 Solutions Manual for DSP using Matlab (2nd Edition) 211 P5.1) Now the DFT X (k) can be written as X (k) = = = N−1 X n=0 ν−1 X x(n)W Nnk = x(m) W Nmk m=0 ν−1 X 3 X ν−1 X p=0 m=0 3 X pνk WN p=0 x(m) W Nmk m=0 " 1 (m+ pν)k x(m + pν)W N = ν−1 X x(m) W Nmk m=0 1 − W NNk N(k/4ℓ) − WN # = 3 X 3 X ν−1 X = [∵ (5.-1.0000 + 0.0. −2. 0≤m ≤ν−1 (5.0000i 0.0000i -0.1.3205i −N/2 [∵ −1 = W N Non-zero.N) -17. 3.3205i + 0. 1. 1.1.2) Now the DFT X (k) can be written as X (k) = = = N−1 X n=0 ν−1 X x(n)W Nnk = x(m) W Nmk m=0 ν−1 X m=0 3 X ν−1 X p=0 m=0 3 X (m+ pν)k x(m + pν)W N pνk (−1) p W N p=0 x(m) W Nmk " 1 − W NN(k−2) 1 − W Nν(k−2) = # ν−1 X x(m) W Nmk m=0 =  = 3 X ν−1 X pνk (−1) p x(m) W Nmk W N p=0 m=0 3  X −N/2 WN p=0 W Nνk p Verification for x(n) = {1.2.0000i -0.0000 .-2.2. −1.0000 + 3. 2. Let N = 4ν where ν is an integer. k = 4ℓ + 2 for 0 ≤ ℓ ≤ ν − 1. 3.3.0000i 0. k 6 = 4ℓ + 2 for 0 ≤ ℓ ≤ ν − 1.3]. Let n = m + pν.1)] p=0 m=0 W Nνk p=0  pνk x(m) W Nmk W N p = ν−1 X x(m) W Nmk m=0  1 − W NNk 1 − W Nνk  Non-zero. length(x).0. 0 ≤ p ≤ 3 (5.0000 . 1.0000 -6.4641i 0. k 6 = 4ℓ for 0 ≤ ℓ ≤ ν − 1. 2.0000i +17. x = [1.0000i -0.0. 3}. 0000 -25. It is given that x(n) = −x(n + ν) for all n.0. −1. 0 ≤ m ≤ ν − 1.0000i 2.0000 + 0.3]. 1. 0 ≤ p ≤ (2µ − 1). 0 ≤ p ≤ (2µ − 1) (5. 0.-1. 3.0000 0.0000 .-2. −2.9808i -0.N) + + 5. 3.0000i 0.0000i -0.0.0000i -0.0000 + 0.0000 0.15 Let X (k) be an N -point DFT of an N -point sequence x(n).0000 0.0000i -0.0000i 3. 0 ≤ m ≤ ν − 1. It is given that x(n) = x(n + ν) for all n.0000 + 0.0000 + 0. 0 ≤ m ≤ ν − 1.0. −2.1.0.-3.0000i -0.0000i -0.0000i -9.0000 . X = dft(x.-1.-2. N = length(x).0000i 0.0000i 0.0000 .1.0.3. −2.3. k = 2µℓ + 2 = 2(µℓ + 1).0000 0.-2.3)] p=0 m=0 p W Nνk = ν−1 X x(m) W Nmk m=0  1 − W NNk 1 − W Nνk  Non-zero. −3. −2.0000 . −1.0. 3. x = [1.4)] −N/2 [∵ −1 = W N ] 6 = 0. 3.0000 .-3]. −3. 0 ≤ p ≤ (2µ − 1).0000i 0.0000i -0.0000i 3.-3.0000i 0. 1.0000 + 0.3) Now the DFT X (k) can be written as X (k) = = = N−1 X n=0 ν−1 X x(m) W Nmk m=0 ν−1 X 2µ−1 ν−1 XX x(n)W Nnk = p=0 m=0 2µ−1 X pνk WN p=0 x(m) W Nmk m=0 " (m+ pν)k x(m + pν)W N = ν−1 X m=0 1 − W NNk 1− x(m) W Nmk N(k/2µ) WN # = 2µ−1 X p=0 =  2µ−1 ν−1 XX pνk x(m) W Nmk W N [∵ (5.1962i .3.-1.0000i 36. k 6 = (2µ)ℓ for 0 ≤ ℓ ≤ ν − 1.0000i -0.0000i -0. 1. 3}.N) X = 12. 2.0000 .0000 + 0.0000 . Verification for x(n) = {1.9808i 0.0.0000i -0.0000 . 3.0000 . Verification for x(n) = {1. x = [1. 1.4) Now the DFT X (k) can be written as X (k) = = = N−1 X n=0 ν−1 X x(n)W Nnk = x(m) W Nmk m=0 ν−1 X m=0 2µ−1 ν−1 XX p=0 m=0 2µ−1 X (−1) x(m + p pνk WN p=0 x(m) W Nmk " 1 − W NN(k−2) 1− (m+ pν)k pν)W N = N(k−2)/(2µ) WN ν−1 X x(m) W Nmk m=0 # = = 2µ−1 ν−1 XX p=0 m=0 2µ−1 X p=0  pνk (−1) p x(m) W Nmk W N −N/2 WN W Nνk p [∵ (5.2.1. 0 ≤ ℓ ≤ ν − 1.0000i -0.0. 2.2.0000i -0.-2. 3. X = 0 -0. 1. 0 ≤ p ≤ (2µ − 1) (5.0.0000 + 0. −2.0000i 0.1962i 0.0.0000 .3.0000 . then x(n) = −x(n + ν) ⇒ x(m + pν) = (−1) p x(m).0000 .1. −3}.3.0000 0. 3.0000 -0.3. Let n = m + pν.0000i 5.0000 + 0.0000 . 1. Let n = m + pν.-2.2.0.-2.-2.0000 .1. −1.0000 -0.0. 3.0000i 0. −2.0000 + 0.0000 -0. k 6 = 2µℓ + 2 = 2(µℓ + 1). k = (2µ)ℓ for 0 ≤ ℓ ≤ ν − 1. 0.-2.0000i X = dft(x.0000i -9.0.3.0000i -0. 1. then x(n) = x(n + ν) ⇒ x(m + pν) = x(m). N = length(x). −2.1. 0 ≤ ℓ ≤ ν − 1. 1.1.3.0. 2. 0 ≤ m ≤ ν − 1. −2.0000 +25.0000 + 0.0000 + 0. Let N = 2µν where µ and ν are integers. −2.-2.Solutions Manual for DSP using Matlab (2nd Edition) 212 2006 P5. 0000 .0000i through 10 0.N).9511i 0.0.0000 Columns 1.0.8090 .8090 + 0.0000 + 0. y(n) = x((n + 4)))1 0: Circular shift by −4.9511i difference = 2.2π k).8090 + 0.N).3090 .0000 Columns 1.5878i 0.5878i Columns 9 through 0.9511i 1.5878i 0. m = -4.N) difference = abs(max(Y-Y1)) Y = Columns 1. Matlab script: k = 0:9.0000i -1.0000i -1. X = exp(j*0.9511i 8 4 8 2.8090 + 0.3090 .3090 + 0.0000 .0000 + 0.0.2006 Solutions Manual for DSP using Matlab (2nd Edition) 213 P5.N)).0000 + 0.5878i 0. y = cirshftt(x. y = cirshftt(x.5878i 0. 1.0. m = 5.0000 Columns 5 through -0.9511i 1.N)).0000i 1. WN = exp(-j*2*pi/N).8090 . N = length(X).0000 + 0.0.0.0000 + 0.0000i 10 -0.0000i 1 through 4 -1.^(m*k) % verification x = real(idft(X.*WN.0000 .0000i .9511i -0. WN = exp(-j*2*pi/N).3090 + 0.0000 .5878i -0.0000 1 through 4 5 9 - -1. Y = X.0000i 1.16 Let X (k) and Y (k) be 10-point DFTs of two 10-point sequences x(n) and y(n).N) difference = abs(max(Y-Y1)) Y = Columns 1 through 1.0000 Y1 = Columns 1.8090 .*WN.0000 + 0. Y1 = dft(y. X = exp(j*0. Y1 = dft(y.3090 + 0.0000i 10 -0.0000 + 0.3090 + 0.0000i -1.0000i -1.m.0.m.0.0000i 1.3090 . y(n) = x((n − 5)))1 0: Circular shift by 5.8090 .7756e-015 4 -0.2*pi*k).5878i -0.0000 + 0.8090 + 0.2*pi*k).0000i -1. Y = X.0.9511i 0.0. Matlab script: k = 0:9.3090 .9511i Y1 = Columns 1 through 1.0. N = length(X).0000 Columns 5 through -0. respectively where X (k) = exp( j 0.0000i through 8 0.0. 0 ≤ k ≤ 9 Computation of Y (k) properties of the DFT.5878i Columns 9 through 0.^(m*k) % verification x = real(idft(X. 8090 + 0.9511i 1. y(n) = x(n)e j 3πn/5 : Circular shift in the freq-domain by 3.0000i -0.0.^(-l*n).9511i 0. X = exp(j*0.8090 + 0.0000i Columns 9 through 10 1.8090 + 0.8090 .0000 Columns 5 through 0.5878i 0.5878i -0.8090 .0000i 2006 -1.*WN.0.3090 + 0. Y1 = dft(y.3090 + 0.3090 + 0.0.3090 + 0.5878i 1.9511i Columns 9 through -0.0000i -1.0000 -0.9511i -0.8090 + 0.N).m.5878i 0.3090 .0.0.5878i 8 4 8 4. WN = exp(-j*2*pi/N). y(n) = x((3 − n)))1 0: Circular-fold and circular-shift by 3.0000 Columns 5 through 0.9511i -0.0. N = length(X). y = cirshftt(x.8090 .9511i -0.0.3090 Columns 0.0000i 10 0. n = 0:9.*WN.6790e-015 4 0.5878i difference = 2.0000i difference = 2.0.0000 + 0.0000i -1. Y1 = dft(y.0. Matlab script: k = 0:9.N) % verification x = real(idft(X.8090 + 0.2249e-015 1.0000 .0000 .5878i 0.l.5878i -0.5878i Y1 = Columns 1 through 1.3090 .9511i Columns 9 through -0. WN = exp(-j*2*pi/N).3090 + 0.3090 . y = x.0000 + 0. y = circfold(x.^(m*k) % verification x = real(idft(X.0000 1 5 + 9 + through 4 0.9511i through 8 0.5878i -0.0000 .Solutions Manual for DSP using Matlab (2nd Edition) 214 Columns 5 through 8 1.2*pi*k).9511i -0.0. N = length(X).9511i 0.8090 .0.8090 Columns -1.0.5878i 1.8090 . l = 3.N)).N). m = 3.3090 + 0.8090 .N) difference = abs(max(Y-Y1)) Y = Columns -0. Y = X. X = exp(j*0.0000 + 0.0000i 10 0. Y = circfold(X.0000 .3090 .N).N)).5878i .0.0. Y = cirshftt(X. Matlab script: k = 0:9.0.2*pi*k).3090 .9511i through 10 0.0000 + 0.0000i 3.9511i 0.N) difference = abs(max(Y-Y1)) Y = Columns 1 through 1. 0000 .0000 .*Y % verification x = real(idft(X.0000 .N).0000i 1.0000i Columns 9 through 1.0.y.0. y = circonvt(x.N) difference = abs(max(Y-Y1)) Y = Columns 1 through 1.0.0000i Columns 9 through 1.0. Y1 = dft(y.8090 .9511i 0.0000 .0000 .3090 + 0.0000i 1.0.8090 + 0. Matlab script: k = 0:9.0000i 1.5878i 5.0000i 1.0000 + 0.0000i 10 1.8090 + 0.0000i 1.5878i difference = 3.0. Y = circfold(X.0.N).0000 .9511i -0.0000 . X = exp(j*0.0000 .0000i 1.0000 + 0.0000i 1.0000i Columns 5 through 1.3090 .0000 .0. N = length(X).0.0000 + 0.0000 + 0.3090 + 0. y(n) = x(n)(10)x((−n))1 0: Circular convolution with circularly-folded sequence.8090 .0000i difference = 4. y = circfold(x.N).0000i 1.0000 .0000i 1.0.0.7761e-015 4 1.9511i Columns 9 through 10 -1.0000 + 0.N)).0000i 1.0000i Columns 5 through 1.0. Y = X.0.0000i 8 4 8 .0000 Y1 = Columns 1 through 1.0000 + 0.0000i 1.9511i Columns 5 through 8 0.2*pi*k).0000 -0.0000 .0000 .0.0000i 10 1.2006 Solutions Manual for DSP using Matlab (2nd Edition) Y1 = Columns 1 through 4 -0.0.3090 .3880e-015 215 0.0000 + 0.0.0000 .0.5878i 1.0000i -0.5878i 0. 4727i -3.9914 + 2.4712 difference = 1.3814 + 1.0000i -3. X12 = dft(x1. −2 + j 3.7520 1.6000 -2. X = [X.3814 .0217 1.0000i 5.1.3+j*4.0000i -3. 2 − j 3. X = [10.6188 0.9914 .9751i -4. 4 + j 5.4727i -3.1.1. x1 = cirshftt(x1.3814 .7782 .2591i -3.2515i 0. x1 (n) = x((2 − n))1 0: Circular-folding followed by circ-shifting by 2.N).4727i -3.2462e-014 -1.m.12]. 3 + j 4.2591i -3.4712 + Columns 5 through 8 5.2.9914 + 2.2.17 The first six values of the 10-point DFT of a real-valued sequence x(n) are given by {10.3814 + 1.2591i 12.9914 .0000 + 0.0000 + Columns 9 through 10 -4.4712 + Columns 5 through 8 5.N).3951 3. k = 0:N-1.7782 + 1.9751i 0.216 Solutions Manual for DSP using Matlab (2nd Edition) 2006 P5.conj(X(5:-1:2))].*X1 % Matlab Verification x1 = circfold(x.N)) WN = exp(-j*2*pi/N).2-j*3. Matlab script: N = 10. X1 = (WN.2515i 0.0000 + Columns 9 through 10 -4.9571 X1 = Columns 1 through 4 10.7782 .2000 0.0000i 5.^(m*k)).4727i -3. 12} DFT computations using DFT properties: 1.2397 1.4712 X12 = Columns 1 through 4 10.9751i .2515i 0.2591i 12.9751i -4.7782 + 1. X1 = circfold(X.4132 1.0721 Column 8 through 10 0. x = real(idft(X. m = 2.N).1.4+j*5.N) difference = max(abs(X1-X12)) x = Columns 1 through 7 3.0000 + 0.2515i 0.-2+j*3. X22 = dft(x2. k = 0:N-1.0000i -12.0000 .12].0000i 2.0000 .7520 1.2000 0.N)) WN = exp(-j*2*pi/N).3.0000 .5.5.0000 Columns 5 through 8 4.^(m*k)).0000 + 5.N).2-j*3. X = [X.0000i 0.*dft(x.4132 1.0721 Column 8 through 10 0.m.0000i 3.0000i -2. Matlab script: N = 10.0000i 3. X = [10.0000 + X22 = Columns 1 through 4 10.6188 3.0000i -12. x2 (n) = x((n + 5))10 : 10-point circular shifting by −5.0000i .0000i 2.4+j*5.0000i 3.4. m = -5.conj(X(5:-1:2))].0000 + 4. X2 = (WN.0000 .9571 X2 = Columns 1 through 4 10.N) % Matlab verification x2 = cirshftt(x.0217 1.-2+j*3.0000i 3.2006 Solutions Manual for DSP using Matlab (2nd Edition) 217 2.0000 + Columns 9 through 10 3.0000i 3.2150e-014 -1.0000i 4.0000i -2.0000 2.0000i -2.2397 1.0000 2.0000 + 3.0000 Columns 5 through 8 4.3951 3.N) difference = max(abs(X2-X22)) x = Columns 1 through 7 3.3.0000 Columns 9 through 10 3.0000 + difference = 3.6000 -2.3+j*4.0000 + 4.0000i 4. x = real(idft(X.0000 .0000i -2.0000i 0.0000 + 5.0000 + 3.0000 .4. 0000i 12.218 Solutions Manual for DSP using Matlab (2nd Edition) 2006 3.0.0.4000 .0000i 0.0000i -2.3951 3.0000i 6.0217 1.0000i 10.N)) X3 = circfold(X.0000i 2.0000i 24.0.6000 -2.0000i 4.0000i 24.2000 + X32 = Columns 1 through 4 19. X = [10.X3.2000 Columns 5 through 8 10.4132 1.0000i 6.0000 + Columns 9 through 10 3.4000 + 0.0000i 3.2397 1.N) difference = max(abs(X3-X32)) x = Columns 1 through 7 3.0000i 10.N).6000 .0000i 10.0000i 10.3.0000i 0.6000 .N)/N % Matlab verification x3 = circfold(x.3+j*4. X32 = dft(x3. X3 = circonvf(X.5.7520 1.0000 Columns 5 through 8 4.0000i 0.-2+j*3.4000 + 0. x3 (n) = x(n)x((−n))10 : Multiplication by circularly-folded sequence.conj(X(5:-1:2))].0000 .0. X = [X.9571 X3 = Columns 1 through 4 10.*x3. x3 = x.0000i 15.0000 .4416e-014 -1.2000 + 0.0.4.2-j*3. x = real(idft(X.6188 3.2000 Columns 5 through 8 10.8000 .0000i 0.0000 + X3 = Columns 1 through 4 19.0000i .0000 + 3.0000i 2.12].0000 .2000 + 0.6000 + 0.0000 + 4.0000i 3.0.0000i 15.0000i 10.0000i 6.0000 + 0.0000 + 5.6000 + 0.2000 difference = 2.4+j*5.0000i 10. Matlab script: N = 10.N).0721 Column 8 through 10 0.4000 .8000 + 0.0000i -2.0000i 0.8000 + 0.2000 0.8000 .4000 + Columns 9 through 10 15.0000i 6.4000 Columns 9 through 10 15.0000i 0.0000i 0. 3951 3.2-j*3.6188 Column 8 through 10 0.0.1300 .N).0217 1.x(mod(-n.2006 Solutions Manual for DSP using Matlab (2nd Edition) 4.0000i difference = 1. X42 = dft(x4.2397 1.4132 1. n = [0:N-1].* X0 % Verification x4 = circonvt(x.0e+002 * Columns 1 through 4 1. X = [10.N)) X0 = X(mod(-k.0000i 0. x = real(idft(X.4100 + 0.N)+1).3+j*4. x4 (n) = x(n) 10jx((−n))10 : 10-point circular convolution with a circularly-folded sequence. Matlab script: N = 10. X = [X.12].2500 + 0.1300 + 0.0.0000i 0.0000i Columns 5 through 8 0.0721 -1.0. X4 = X .0000i 1.4400 + 0.0000i 0.0000i 0.9571 X4 = 100 13 25 13 41 144 41 13 25 13 X42 = 1.7520 1.-2+j*3.0378e-013 219 .1300 .2000 0.0000 0.6000 -2.N) difference = max(abs(X4-X42)) x = Columns 1 through 7 3.0000i 0.4+j*5.N)+1).1300 + 0.0.2500 .4100 .conj(X(5:-1:2))].0000i Columns 9 through 10 0. 0000 difference = 2.4.0000 Columns 5 through 8 3.0000 .0000 .0000 .0000i 2. x5 = x.0000i -2.0000i 12.0000 + 4. n = [0:N-1].0000 + 3.0000 + 3.*(WN.7520 1.0000 X51 = Columns 1 through 4 4. Matlab script: N = 10.0000i 3.0000 + Columns 5 through 8 3.N) difference = max(abs(X5-X51)) x = Columns 1 through 7 3.12].N)) X5 = [X(m+1:end). X = [10.0000i 2.3951 3.0217 1.2397 1. X51 = dft(x5.0000i 10.0000 Columns 9 through 10 3.5.X(1:m)] % Verification WN = exp(-j*2*pi/N).0000i 4.6000 -2.4895e-014 -1.0000i 12.4.9571 X5 = Columns 1 through 4 4.0000i 0.2-j*3.0000i .0000 + 4.0000 + 5.220 Solutions Manual for DSP using Matlab (2nd Edition) 2006 5.0000 + 5.0000i 2. x = real(idft(X.0000i 3.0000i -2.0000 + 0.4132 1.0000i -2.^(m*n)). x5 (n) = x(n)e− j 4πn/5 : Circular-shifting by −4 in the frequency-domain.0000i 3.6188 2.0000i 10.-2+j*3.0000 + 3.0000 . X = [X.2000 4.0000 Columns 9 through 10 3. m = 4.conj(X(5:-1:2))].0000i 3.3+j*4.0000 0.0000 + 3.5.0000i -2.4+j*5.0721 Column 8 through 10 0. ’filled’).4).4]).imag(X).2). set(H_s3.2. n = 0:N-1.[0. Using the DFT properties of conjugation and circular folding.’markersize’.’markersize’. ylabel(’Amplitude’). title(’X_I(k)’).3’). ylabel(’Amplitude’).’position’. subplot(2.18. then xccs (n) . set(H_s1.1*pi*k).5.1π k)][u(k) − u(k − 20)] be a 20-point DFT.’P5.’off’.-4.0.[0. Xccs = dft(xccs. axis([-0. H_s4 = stem(n. title(’X_{ccs}(k)’).5. xcca] = circecod(x) % N = length(x).’color’.. we obtain   1 DFT [x(n)] + DFT x ∗ ((−n)) N 2 o 1n ˆ = = DFT [x((−n)) N ] X (k) + Xˆ ∗ ((−k)) N .0. axis([-0.conj(x(mod(-n.imag(Xcca).2.1.5. Matlab verification: N = 20..real(X). H_s3 = stem(n. x = idft(X.2π k) + j 4 sin(0. ylabel(’Amplitude’).1.3).’markersize’. [xccs. xlabel(’k’). n = 0:(N-1).’Name’. xccs = 0. title(’X_{cca}(k)’).4]. xcca = 0.5.N). k = 0:N-1.20.’filled’).2*pi*k) + j*sin(0.3).[1.0]). H_s1 = stem(n.real(Xccs).18 Complex-valued N -point sequence x(n) can be decomposed into N -point circular-conjugatesymmetric and circular-conjugate-antisymmetric sequences using the following relations  1 x(n) + x ∗ ((−n)) N 2  1 xcca (n) .2006 Solutions Manual for DSP using Matlab (2nd Edition) 221 P5.N). ylabel(’Amplitude’). Xcca = dft(xcca. Let X (k) = [3 cos(0.1]). DFT [xccs (n)] = X R (k) and DFT [xcca (n)] = j X I (k) 1.2. Hf_1 = figure(’Units’.4]).6.1. H_s2 = stem(n.3). axis([-0. x(n) − x ∗ ((−n)) N 2 If X R (k) and X I (k) are the real and imaginary parts of the N -point DFT of x(n).’markersize’.4].N)+1))). The plots are shown in Figure 5.-1.20.5.5. The modified circevod function: function [xccs. ’paperunits’.1]).20.N)+1))). xcca] = circevod(x) % Complex-valued signal decomposition into circular-even and circular-odd parts % ----------------------------------------------------------------------------% [xccs. where X(k) 2 1 = X (k) + X ∗ (k) = Re [X (k)] = X R (k) 2 DFT [xccs (n)] = similarly.N). set(H_s2. xcca] = circevod(x).5.3).-4. subplot(2.’filled’).’NumberTitle’.’paperposition’. we can show that DFT [xcca (n)] = j Im [X (k)] = j X I (k) 2.-1. xlabel(’k’). title(’X_R(k)’).20. set(H_s4. set(Hf_1. subplot(2. .3).5..’filled’).2. axis([-0.1).1.’inches’.5*(x .6.5*(x + conj(x(mod(-n.1. subplot(2.’inches’. X = 3*cos(0. 3.13. 13: Plots in Problem P5.Solutions Manual for DSP using Matlab (2nd Edition) 222 XR(k) XI(k) 4 1 Amplitude Amplitude 2 0 0.5 0 −0.18.3 10 k .5 −2 −1 −4 0 5 10 15 20 0 5 X (k) 10 X ccs 15 20 15 20 (k) cca 4 1 Amplitude 2 Amplitude 2006 0 0.5 0 −0.5 −2 −1 −4 0 5 10 k 15 20 0 5 Figure 5. then DFT [xR (n)] = X ccs (k) and DFT [ j xI (n)] = X cca (k) where X ccs (k) and X cca (k) are the circular-even and circular-odd components of X (k) as defined in Problem 5. x2 = [x2 zeros(1.N).x2.N) % DFTs of two real sequences % [X1. N2 = length(x2). X2] = circevod(X). 1. DFT [ j xI (n)] = {DFT [x(n)] − DFT [x (n)]}  X cca (k) 2 ⇒ X I (k) = = − j X cca (k) 1  j  {X (k) − X ∗ ((−k)) N } .N) % X1 = N-point DFT of x1 % X2 = N-point DFT of x2 % x1 = real-valued sequence of length <= N % x2 = real-valued sequence of length <= N % N = length of DFT % % Check for length of x1 and x2 if length(x1) > N error(’*** N must be >= the length of x1 ***’) end if length(x2) > N error(’*** N must be >= the length of x2 ***’) end N1 = length(x1).18. .19 (Two real DFTs using one complex DFT) If X (k) is the N -point DFT of an N -point complex-valued sequence x(n) = xR (n) + j xI (n) where xR (n) and xI (n) are the real and imaginary parts of x(n). X = dft(x. Analytical proof: Consider   1 DFT [x(n)] + DFT x ∗ (n) 2 1 = X (k) + X ∗ ((−k)) N .N-N1)]. X cca = 2 2.X2] = real2dft(x1. Matlab function real2dft: function [X1.X2] = real2dft(x1.x2. let x1 (n) and x2 (n) be two N -point sequences. x = x1 + j*x2. DFT [xR (n)] = Similarly  1 ∗  j X I (k) . Then we can form a complex-valued sequence x(n) = x1 (n) + j x2 (n) and use the above property. [X1. This property can be used to compute the DFTs of two real-valued N -point sequences using one N point DFT operation. X2 = X2/j. X ccs 2 X R (k) .N-N2)]. x1 = [x1 zeros(1. Specifically.2006 Solutions Manual for DSP using Matlab (2nd Edition) 223 P5. N). xcca] = circecod(x) % N = length(x). [X1. x1 = cos(0.N). xccs = 0.6876e-013 difference = 3. Compute and plot the DFTs of the following two sequences using the above function x1 (n) = cos(0.N).5*(x . X11 = dft(x1. x2 (n) = sin(0. xcca] = circevod(x) % Complex signal decomposition into circular-even and circular-odd parts % ---------------------------------------------------------------------% [xccs.2*pi*n).N)+1))).conj(x(mod(-n.X2] = real2dft(x1.224 Solutions Manual for DSP using Matlab (2nd Edition) 2006 We will also need the circevod function for complex sequences (see Problem P5. n = 0:(N-1). 0 ≤ n ≤ 39 Matlab verification: N = 40. This can be obtained from the one given in the text by two simple changes.x2.2π n). X21 = dft(x2. x2 = sin(0.N)+1))).6564e-013 .1π n).18).1*pi*n). difference = max(abs(X1-X11)) difference = max(abs(X2-X21)) difference = 3. n = 0:N-1. function [xccs. xcca = 0.5*(x + conj(x(mod(-n. 3. if Rx > 1 error(’*** x must be a vector ***’) % stop if x is a matrix end % Check for length of x if length(x) > N error(’N must be >= the length of x’) end x=[x zeros(1.20 Circular shifting: The Matlab routine cirshftf. % make sure that m is a row vector end [Rm. each row is a circular shift % in x corresponding to entries in vecor m % M and x should not be matrices % % Check whether m is scalar. each row of which is a circular shift in x(n) corresponding to entries in the vector m. or matrix [Rx. % make sure that x is a row vector end [Rx. . If m is a vector then y(n) is a matrix.Cx] = size(x). vector. If m is a scaler then y(n) is circularly shifted sequence (or array). if Rm > 1 error(’*** m must be a vector ***’) % stop if m is a matrix end % Check whether x is scalar. x((n − m)) N = IDFT X (k)W Nmk This routine will be used in the next problem to generate a circulant matrix and has the following features.m.N) % Circular shift of m samples wrt size N in sequence x: (freq domain) % ------------------------------------------------------------------% function y=cirshift(x. or matrix [Rm.N-length(x))].N).Cm] = size(m).m. X=dft(x.N) % y : output sequence containing the circular shift % x : input sequence of length <= N % m : sample shift % N : size of circular buffer % % Method: y(n) = idft(dft(x(n))*WN^(mk)) % % If m is a scalar then y is a sequence (row vector) % If m is a vector then y is a matrix. function y = cirshftf(x.Cm] = size(m).Cx] = size(x).m to implement circular shift is written using the frequencydomain property   y(n) .2006 Solutions Manual for DSP using Matlab (2nd Edition) 225 P5. vector. if Rm > Cm m = m’. if Rx > Cx x = x’. m = 8.N). N = 15.1. Matlab verification: (a) x(n) = {5. y = real(y) y = 1 1 2 0 3 0 4 5 0 0 0 .4. y = cirshftf(x.2.4. 2. 3. WN=exp(-2*j*pi/N).N)))/N. m = −5.N). 0. Y=(WN. 1.2.0.2. 0.2. y = real(y) y = 0 0 1 2 3 4 5 5 4 3 2 1 5 4 3 2 (b) x(n) = {5.1)*X. 4. 3.Solutions Manual for DSP using Matlab (2nd Edition) 226 2006 X=ones(Cm. m = -5. 2. y=real(conj(dfs(conj(Y). y = cirshftf(x.1. 3. 1. 1.4.m. 0. 0. 0 ≤ n ≤ 10.^(m’ * k)). 4}.1. k=[0:1:N-1]. N = 15 ↑ x = [5.3.m. 3. 4.0.0.0.5].1.4.3.*X. m = 8.5]. 2. 4}. 2. N = 12. 1. 0 ≤ n ≤ 10. N = 11 ↑ x = [5.3.3. power_X = (1/N)*sum(X.3.*conj(X)) power_X = 110 227 . N = length(x).N).0. N−1 X n=0 |x (n)|2 = N−1 N−1 1 X 1 X |X (k)|2 X (k) X ∗ (k) = N k=0 N k=0 Matlab verification: x = [5.2.3.0.1.5]. % power of x(n) in the time-domain power_x = sum(x.2.*conj(x)) power_x = 110 % Power in the frequency-domain X = dft(x.21 Parseval’s relation for the DFT: N−1 X n=0 |x (n)|2 = = ) N−1 X 1 x (n) x ∗ (n) = X (k) W N−nk x ∗ (n) N n=0 k=0) ( N−1 n=0 ( N−1 )∗ N−1 N−1 X X X X 1 1 X (k) x ∗ (n) W N−nk = X (k) x (n) W Nnk N k=0 N n=0 k=0 n=0 N−1 X N−1 X ( Therefore.1.2006 Solutions Manual for DSP using Matlab (2nd Edition) P5.4.4. X (152) = 17 + j 23. Thus X (5) = 20 + j 30 = X ∗ (512 − 5) = X ∗ (507) ⇒ X (507) = 20 − j 30 ⇒ k2 = 507 X (480) = −10 − j 15 = X ∗ (512 − 480) = X ∗ (32) ⇒ X (32) = −10 + j 15 ⇒ k1 = 32 X (152) = 17 + j 23 = X ∗ (512 − 152) = X ∗ (360) ⇒ X (360) = 17 − j 23 ⇒ k3 = 360 3.69◦ ) 512  +57. k2 .056 cos(0. Hence 1  X (0) + X (5)e−2π5n/512 + X ∗ (5)e2π5n/512 + X (32)e−2π32n/512 + X ∗ (32)e2π32n/512 512  +X (152)e−2π152n/512 + X ∗ (152)e2π152n/512 + X (256)e−2π256n/512    1  = X (0) + 2Re X (5)e−2π5n/512 + 2Re X (32)e−2π32n/512 + 2Re X (152)e−2π152n/512 512  +X (256)(−1)n 1  = 20 + 72.22 A 512-point DFT X (k) of a real-valued sequence x(n) has the following DFT values: X (0) = 20 + j α. X (256) = 30 + jβ and all other values are known to be zero.111 cos(0.201 cos(0. Since N = 512. The real-valued coefficients α and β: Since the sequence x(n) is real-valued. 2. X (5) = 20 + j 30. X (0) and X (256) are real-valued. Sequence x(n) in a closed form: The time-domain sequence x(n) is a linear combination of the harmonically related complex exponential. X (k1 ) = −10 + j 15.Solutions Manual for DSP using Matlab (2nd Edition) 228 2006 P5. and k3 : Again using the conjugate symmetry property of the DFT. X (k) is conjugate symmetric which means that X (0) and X (N/2) are also real-valued.32◦ ) + 36. Hence α = β = 0. we have X (k) = X ∗ (N − k). The energy of the signal x(n): Using Parseval’s relation.082 512 4. The values of the integers k1 .531◦ ) + 30(−1)n x(n) = .59375π n − 53. X (k3 ) = 17 − j 23.125π n − 123. X (480) = −10 − j 15. X (k2 ) = 20 − j 30. Ex = = ∞ X n=−∞ |x(n)|2 = ∞ 1 X |X (k)|2 N k=−∞  1  |X (0)|2 + 2|X (5)|2 + 2|X (32)|2 + 2|X (152)|2 + |X (256)|2 = 12.019531π n − 56. 1. 4. . Hence x((−8 − n))7 R7 (n) = {0. 0. 0. −5. 1} . −3. 4. . 0.2006 Solutions Manual for DSP using Matlab (2nd Edition) 229 P5. 0. else is a circularly folded and circularly shifted-by-(−1) version of the 7-point sequence {1. 2. −3. . 0. . 1. 0 ≤ n ≤ 6 0. ↑ Then the sequence x((−8 − n))7 R7 (n) = x((−[n + 8]))7 R7 (n) = x((−[n + 8 − 7]))7 R7 (n) = x((−[n + 1]))7 R7 (n) where R7 (n) =  1. . . −5. 4. 0}. −3. 2. 0. 2.23 Let x(n) be a finite length sequence given by   x(n) = . −5. Using the results from Example 5. X2 =  3 2 1 4  0 4 3 2 1 The matrix X2 has the property that its every row or column can be obtained from the previous row or column using circular shift. 2. x3 (n) . x2 (n) = {1. 2.24 Circular convolution using circulant matrix operation. 4} . It is completely described by the first column or the row. 2.13. x1 (n) 4jx2 (n) 1. 3. 2} . Such a matrix is called a circulant matrix. Circular convolution:  1  2 x3 = X2 x1 =   3 4 4 1 2 3 3 4 1 2  2 1  2 3   4  2 1 0    15   12  =    9  14 .230 Solutions Manual for DSP using Matlab (2nd Edition) 2006 P5. x1 (n) = {1. we can express the above signals as     1 1 4 3 2  2   2 1 4 3     x1 =   2  . 0000 2.0000 3. [x.m.0000 2.0000 1.0000 x3 = X2*x1’.0000 231 . x3 = x3’ x3 = 15.N) % % C : Circulant matrix % x : input sequence of length <= N % N : size of the circular buffer % Method: C = h((n-m) mod N).0000 4.2006 Solutions Manual for DSP using Matlab (2nd Edition) P5. x2 = [1.0000 12. 0:N-1.0000 3.2. circfold(x.0000 14.N).0000 4.0000 2.N) % Circulant matrix generation using vector data values % ---------------------------------------------------% function C = circulnt(h.0000 3.N).4].1)].N) X2 = 1. X2 = circulnt(x2.2. % % % % % % length of x zero-pad x establish size of C indices n and m Circular folding Circular shifting Matlab verification on sequences in Problem 5. x1 = [1.25 Matlab function circulnt: function C = circulnt(x.0].0000 4.2.0000 1. Mx x C m x C = = = = = = length(x).3.N).0000 1.0000 4.0000 3. zeros(N. cirshift(x.0000 2. zeros(N-Mx.0000 9.24: N = 4. 1].Solutions Manual for DSP using Matlab (2nd Edition) 232 P5.3.N) % %function y=circonvf(x1. 3. x3 = circonvf(x1. 2.2.x2.4]. X2=fft(x2). y=real(ifft(X1. 1} 4j{1.26 Matlab function circonvf: function y = circonvf(x1. 3.4) x3 = 24 22 24 30 2006 . x2=[x2 zeros(1.*X2)).x2.3.N) % % N-point circular convolution between x1 and x2: (freq domain) % ------------------------------------------------------------% y : output sequence containing the circular convolution % x1 : input sequence of length N1 <= N % x2 : input sequence of length N2 <= N % N : size of circular buffer % % Method: y(n) = idft(dft(x1)*dft(x2)) % Check for length of x1 if length(x1) > N error(’N must be >= the length of x1’) end % Check for length of x2 if length(x2) > N error(’N must be >= the length of x2’) end x1=[x1 zeros(1.N-length(x1))]. 4}: x1 = [4.x2.2.N-length(x2))]. X1=fft(x1). x2 = [1. 2. Circular convolution {4. 7. −1}. x4 (n) = x1 (n) 5jx2 (n) ↑ ↑ 1.2006 Solutions Manual for DSP using Matlab (2nd Edition) P5. Linear convolution x3 (n): x3 (n) = x1 (n) ∗ x2 (n) = {2. 3.27 The following four sequences are given: x1 (n) = {1. for N = 5. −1. 2. x3 (n) = x1 (n) ∗ x2 (n). x2 (n) = {2. 7. −1}. 0. e(0) = x4 (0) − x3 (0) = x3 (5) ⇒ x4 (0) = x3 (0) + x3 (5) = 2 − 2 = 0 e(1) = x4 (1) − x3 (1) = x3 (6) ⇒ x4 (1) = x3 (1) + x3 (6) = 7 + 1 = 8 e(2) = x4 (2) − x3 (2) = x3 (7) ⇒ x4 (2) = x3 (2) + x3 (7) = 7 + 0 = 7 e(3) = x4 (3) − x3 (3) = x3 (8) ⇒ x4 (3) = x3 (3) + x3 (8) = −1 + 0 = −1 e(4) = x4 (4) − x3 (4) = x3 (9) ⇒ x4 (4) = x3 (4) + x3 (9) = −4 + 0 = −4 233 . Computation of x4 (n) using x3 (n) alone: The error in the two convolutions is given by e(n) . −2. 1} ↑ 2. x4 (n) − x3 (n) = x3 (n + N ) we have. 1. −4. .min(x3)-1. N = 32: Matlab script: N = 32.’NumberTitle’. ’color’.’fontsize’.’position’. x3 = circonvt(x1.0].’inches’.[0.[0.[1.’Name’.N).14.3).28.’Name’.1. n2 = 0:7.’paperunits’.n1 = 0:5.’inches’. H_s1 = stem(n.’P5.’markersize’.N.’fontsize’.1. 1. set(Hf_2.10).x3.0.Solutions Manual for DSP using Matlab (2nd Edition) 234 2006 P5.[0.14: The sample plot in Problem P5.1.1.N).5. ’color’. xlabel(’{\itn}’). xlabel(’{\itn}’).15.min(x3)-1.N.’NumberTitle’..1 2.’filled’). Hf_2 = figure(’Units’.10)..’paperposition’.’P5. Hf_1 = figure(’Units’.x2. x1 (n) = cos (2π n/N ) R N (n). set(Hf_1. N = 10: Matlab script: N = 10. n = 0:N-1. The sample plot is shown in Figure 5. ylabel(’Amplitude’)..2 30 .1’).0].2]. Amplitude Circular Convolution x3(n) 10 0 −10 0 5 10 15 n 20 25 Figure 5.’position’.max(x3)+1]).5. title(’Circular Convolution {\itx}_3({\itn})’. x2 = sin(2*pi*n/N). axis([-1.0. x1 = cos(2*pi*n/N).’off’. The sample plot is shown in Figure 5.5]).3). x2 = cos(pi*n2/4). x2 (n) = cos(π n/4)R8 (n).x2.’paperposition’.’off’.2’). axis([-1. Amplitude Circular Convolution x3(n) 2 0 −2 −1 0 1 2 3 4 5 6 7 8 9 10 n Figure 5. set(H_s2.[1.’inches’..x3. H_s2 = stem(n. x3 = circonvt(x1. x1 (n) = sin(π n/3)R6 (n). ylabel(’Amplitude’).5].’inches’.max(x3)+1]). x2 (n) = sin (2π n/N ) R N (n).5..15: The sample plot in Problem P5.0.’paperunits’.’markersize’.28. x1 = sin(pi*n1/3).’filled’). n = 0:N-1.2]). set(H_s1. title(’Circular Convolution {\itx}_3({\itn})’.0.5.28.[0.28.28 Computation and plotting of the N -point circular convolutions between two finite-length sequences. 235 N = 20: Matlab script: N = 20. x2 (n) = (−0. x1 (n) = (0.1. n = 0:N-1.1.28..8). The sample plot is shown in Figure 5.5]).max(x3)+0.8).8)n R20 .’inches’. axis([-1.16. H_s3 = stem(n.’position’. title(’Circular Convolution {\itx}_3({\itn})’. x2 = (-0.28.x3.. set(Hf_3. ylabel(’Amplitude’).3 4. Hf_3 = figure(’Units’.. x1 = (0.17. set(H_s4. Amplitude Circular Convolution x3(n) 1 0. x3 = circonvt(x1. N = 10: Matlab script: N = 10.[0.x2 (n) = u(n) − u(n − 40).[0.16: The sample plot in Problem P5. x1 = n.3’).N).5.N.[0.’inches’.5]). axis([-1.’paperunits’.0].x2.4 5.28.0.’filled’)..’P5. ’color’..10).1.5].’paperposition’.’Name’.5.min(x3)-10.28.^n.1.’off’.5].’paperunits’.5]).17: The sample plot in Problem P5. H_s4 = stem(n.2006 Solutions Manual for DSP using Matlab (2nd Edition) 3.0].10). Hf_4 = figure(’Units’.N). ylabel(’Amplitude’).[1.’NumberTitle’.max(x3)+10]).’P5.3).0.^n.’inches’.x2.1.8)n R N (n). The sample plot is shown in Figure 5.’off’.’Name’.min(x3)-0.8)n R N (n). set(Hf_4. xlabel(’{\itn}’)..[1.’filled’).5 0 2 4 6 8 10 12 14 16 18 20 n Figure 5.5.5.’fontsize’.’fontsize’.4’). Amplitude Circular Convolution x3(n) 300 250 200 −1 0 1 2 3 4 5 6 7 8 n Figure 5.’markersize’.0. title(’Circular Convolution {\itx}_3({\itn})’.5 0 −0.0.’paperposition’.N. set(H_s3. N = 50: Matlab script: 9 10 . x3 = circonvt(x1.’NumberTitle’. ’color’.’markersize’. xlabel(’{\itn}’). x2 = (N-n). x1 (n) = nR N (n).5.1.[0.x3.’position’. n = 0:N-1. x1 (n) = (0. x2 (n) = (N − n)R N (n).’inches’.3). axis([-1. The sample plot is shown in Figure 5.[1.x3.1..’inches’.x2.’paperposition’.’NumberTitle’. n = 0:N-1. H_s5 = stem(n.’paperunits’.5 45 50 .max(x3)+1]).28.^n1.0].18: The sample plot in Problem P5..min(x3)-1.5.10).’fontsize’. title(’Circular Convolution {\itx}_3({\itn})’.5’). x1 = (0. n1 = 0:19.Solutions Manual for DSP using Matlab (2nd Edition) 236 2006 N = 50. Hf_5 = figure(’Units’.3). xlabel(’{\itn}’). set(Hf_5.[0. ylabel(’Amplitude’).5].N).1.5]).40).’Name’.5. x2 = ones(1.0. n2 = 0:39.8).’markersize’. set(H_s5.’filled’).18.’inches’. x3 = circonvt(x1.0. Amplitude Circular Convolution x3(n) 4 2 0 0 5 10 15 20 25 n 30 35 40 Figure 5.’position’.[0.’P5.N.28.1..’off’. ’color’. −4. −74. −7. Let Y (k) be the 8-point DFT of ↑ a sequence y(n) where Y (k) = W85k X ((−k))8 . −5. −16. 2. P N−1 1. 3}. 0} ↑ . −9. −1. −5. −2} Consider x1 (n) = {9. −4. 4. 2. we have   y(n) = IDFT W85k X ((−k))8 = IDFT [X ((−k))8 ]n→(n−5)   = x((−n))8 |n→(n−5) R8 (n) = x((5 − n))8 R8 (n) = {0. 2. 6. −57. 6. 4. −1. 0. −2} ⇒ y(n) = x1 (n) Hence 8jx 2 (n) 7 X n=0 x1 (n) = 22 7 X n=0 x2 (n) = −7 = {14. −7. x2 (n) = {−5. −1. 2. 2. −32. 0. −4.2006 Solutions Manual for DSP using Matlab (2nd Edition) 237 P5.29 Let x1 (n) and x2 (n) be two N -point sequences. 4. Since y(n) = x1 (n) Njx2 (n) = k=0 x1 (k) x2 ((n − k)) N we have N−1 X n=0 y(n) = = = = N−1 X N−1 X n=0 k=0 N−1 X x1 (k) x2 ((n − k)) N = x1 (n) n=0 N−1 X " k−1 X n=0 x1 (n) " N−1 X N−1 X x1 (n) n=0 ! x2 (n) + N−1 X x2 (n) n=0 ! x1 (k) k=0 x2 (n − k + N ) + n=N−k n=0 N−1 X N−1−k X n=0 N−1 X n=0 N−1 X n=k x2 ((n − k)) N x2 (n − k) # x2 (n) = N−1 X # x1 (n) n=0 " N−k−1 X n=0 x2 (n) + N−1 X x2 (n) n=N−k # 2. 4. 0. 5.30 Let X (k) be the 8-point DFT of a 3-point sequence x(n) = {5. 3. −7. 2. −4. Verification using the following sequences: x1 (n) = {9. 27} ⇒ y(n) = −154 = (22) × (−7) = 7 X n=0 x1 (n) ! 7 X n=0 7 X n=0 x2 (n) y(n) = −154 ! P5. −1. 8. 3} ⇒ 7 X n=0 x2 (n) = {−5. 3}. Then using the circular folding and the circular shifting properties of the DFT. 8. circonvt(x1. 1.19. conv(x1. e2 = x4(N+1:end).19: The sample plot of various signals in Problem P5.31. The plots of various signals are shown in Figure 5.1 .N). Circular Convolution: x3(n) Amplitude 2 1 0 −1 −2 −3 −1 0 1 2 3 4 5 6 7 8 9 6 7 8 9 6 7 8 9 6 7 8 9 Linear Convolution: x4(n) Amplitude 2 1 0 −1 −2 −3 −1 0 1 2 3 4 5 Error: x3(n) − x4(n) Amplitude 2 1 0 −1 −2 −3 −1 0 1 2 3 4 5 Error: x4(n+N) Amplitude 2 1 0 −1 −2 −3 −1 0 1 2 3 4 n 5 Figure 5. N = 8: x1 x3 x4 e1 = = = = [1.1. n4 = 0:length(x4)-1.Solutions Manual for DSP using Matlab (2nd Edition) 238 2006 P5. x2 = cos(pi*[0:5]/4).1]. N = 8.x4(1:N). n = 0:N-1. (ii) the linear convolution x4 (n) = x1 (n) ∗ x2 (n). 1}.31 Computation of (i) the N -point circular convolution x3 (n) = x1 (n) Njx2 (n). x1 (n) = {1. 1. x3 . x2 (n) = cos(π n/4)R6 (n). and (iii) the error sequence e(n) = x3 (n) − x4 (n) for the following sequences: 1.x2.1.x2). x2. e2 = x4(N+1:end). n4 = 0:length(x4)-1.2006 Solutions Manual for DSP using Matlab (2nd Edition) 239 2.0].N). x1 = cos(2*pi*[0:15]/N). x1 (n) = cos(2π n/N )R16 (n). x2 (n) = sin(2π n/N )R16 (n). x3 = circonvt(x1. x4 = conv(x1.x2). x2 = sin(2*pi*[0:15]/N). n3 = 0:N-1. N = 32: N = 32.20.20: The sample plot of various signals in Problem P5. The plots of various signals are shown in Figure 5.2 . e1 = x3 .[x4. Circular Convolution: x3(n) Amplitude 5 0 −5 0 5 10 15 20 25 30 20 25 30 20 25 30 20 25 30 Linear Convolution: x4(n) Amplitude 5 0 −5 0 5 10 15 Error: x3(n) − x4(n) Amplitude 5 0 −5 0 5 10 15 Error: x4(n+N) Amplitude 5 0 −5 0 5 10 15 n Figure 5.31. x2.5 0 −0.^[0:9]. x4 = conv(x1.5 1 0.8)n R10 (n). n4 = 0:length(x4)-1.31.5 1 0. x1 = (0. e1 = x3 .N).x2).Solutions Manual for DSP using Matlab (2nd Edition) 240 2006 3. x2 = (-0.5 0 −0.x4(1:N).3 .5 0 2 4 6 8 10 12 14 16 18 12 14 16 18 12 14 16 18 12 14 16 18 Linear Convolution: x4(n) Amplitude 1. x3 = circonvt(x1.21. Ne2 = length(e2).8)n R10 (n). n3 = 0:N-1.^[0:9].5 0 −0.5 0 2 4 6 8 10 Error: x3(n) − x4(n) Amplitude 1. x2 (n) = (−0. N = 15: N = 15. The plots of various signals are shown in Figure 5. e2 = x4(N+1:end).5 0 −0.5 0 2 4 6 8 10 n Figure 5.8).5 1 0.5 0 2 4 6 8 10 Error: x4(n+N) Amplitude 1.5 1 0. x1 (n) = (0.8). Circular Convolution: x3(n) Amplitude 1.21: The sample plot of various signals in Problem P5. 31.x2. n3 = 0:N-1.22: The sample plot of various signals in Problem P5. x1 = n. n4 = 0:length(x4)-1.2006 Solutions Manual for DSP using Matlab (2nd Edition) 241 4. n = 0:N-1. x4 = conv(x1. x1 (n) = nR10 (n). x2 = N-n. Ne2 = length(e2). x3 = circonvt(x1. x2 (n) = (N − n)R10 (n). The plots of various signals are shown in Figure 5.22. e1 = x3 .N).4 .x4(1:N). N = 10: N = 10. Circular Convolution: x3(n) Amplitude 300 200 100 0 0 2 4 6 8 10 12 14 16 18 12 14 16 18 12 14 16 18 12 14 16 18 Linear Convolution: x4(n) Amplitude 300 200 100 0 0 2 4 6 8 10 Error: x3(n) − x4(n) Amplitude 300 200 100 0 0 2 4 6 8 10 Error: x4(n+N) Amplitude 300 200 100 0 0 2 4 6 8 10 n Figure 5.x2). e2 = x4(N+1:end). x2 = [1. n4 = 0:length(x4)-1.Solutions Manual for DSP using Matlab (2nd Edition) 242 2006 5.-1. 0}.5 . n = 0:N-1. x1 = [1.1.0. x2 (n) = {1. Ne2 = length(e2).31. 1. −1. The plots of various signals are shown in Figure 5. −1. Circular Convolution: x3(n) Amplitude 2 1 0 −1 −2 −1 0 1 2 3 4 5 6 7 5 6 7 4 5 6 7 4 5 6 7 Linear Convolution: x4(n) Amplitude 2 1 0 −1 −2 −1 0 1 2 3 4 Error: x3(n) − x4(n) Amplitude 2 1 0 −1 −2 −1 0 1 2 3 Error: x4(n+N) Amplitude 2 1 0 −1 −2 −1 0 1 2 3 n Figure 5.23.0]. x4 = conv(x1. x3 = circonvt(x1. e1 = x3 . e2 = x4(N+1:end). n3 = 0:N-1.-1.x2. −1}.-1]. 0. N = 5: N = 5.23: The sample plot of various signals in Problem P5.N).x2). x1 (n) = {1.x4(1:N). h. % Initialize Y matrix % % convolution with succesive blocks for m = 0:M-1 xm = [x(m*L+1:(m+1)*L). . To use DFT for this operation we have to choose N ≥ (2L − 1). y = y1+y2. m L ≤ n ≤ (m + 1)L − 1 so that x(n) = xm (n) xm (n) = 0. 2. . . Divide x(n) into M segments {xm (n).2006 Solutions Manual for DSP using Matlab (2nd Edition) 243 P5.N+1)].N) % y = output sequence % x = input sequence % h = impulse response % N = DFT length >= 2*length(h)-1 % Lx = length(x). In this method we have to save the intermediate convolution results and then properly overlap these before adding to form the final result y(n).zeros(1.zeros(M.h) % High-Speed Overlap-Add method of block convolution .1)]. y = y’. Y1 = Y(:.1:L). zeros(1.N).32 The overlap-add method of block convolution is an alternative to the overlap-save method. . L1 = L-1. Y2 = Y2’. h = [h zeros(1.h. y2 = Y2(:).zeros(1. ym (n) is a (2L − 1)-point sequence. % M = ceil(Lx/L). then y(n) = x(n) ∗ h(n) = M−1 X m=0 xm (n) ∗ h(n) = M−1 X ym (n). m=0 △ ym (n) = xm (n) ∗ h(n) Clearly.L).N). elsewhere m=0 Let h(n) be an L-point impulse response. 1. Y2 = [zeros(1. Let x(n) be a long sequence of length M L where M.N) % Overlap-Add method of block convolution % ---------------------------------------% [y] = ovrlpadd(x. L = length(h).M*L-Lx)].L+1:2*L)]. M} each of length L  M−1 X x(n). % append (M*N-Lx) zeros Y = zeros(M. end % % Overlap and Add Y = [Y. The radix-2 FFT implementation for high-speed block convolution: function [y] = hsolpadd(x.N-L)]. y1 = Y1(:). L ≫ 1.:) = circonvt(xm. Y = [Y. m = 1.Y(1:M. Y1 = Y1’. % Number of blocks x = [x. Y(m+1. y = removetrailzeros(y).N-L)].h. Matlab function to implement the overlap-add method using the circular convolution operation: function [y] = ovrlpadd(x. % Number of blocks x = [x.h). Y(m+1. h(n) = {1. zeros(1.zeros(1. 1. y2 = hsolpadd(x. Verification using the following two sequences x(n) = cos (π n/500) R4000 (n).7).N+1)]. H = fft(h. y = removetrailzeros(y). y = y’.1)]. end % % Overlap and Add Y = [Y.1:L).h). Y2 = Y2’.L).N-L)]. h = [1.1. e1 = max(abs(y1-y3)) e2 = max(abs(y1-y2(1:end-1))) e1 = 2.N)). y2 = Y2(:).zeros(M.L+1:2*L)]. Y = [Y. −1. 3. x = cos(pi*n/500).-1].N). % append (M*N-Lx) zeros Y = zeros(M. y3 = conv(x. y1 = Y1(:).N).-1. Y2 = [zeros(1.h) y = output sequence (real-valued) x = input sequence (real-valued) h = impulse response (real-valued) Lx = length(x). L = length(h).zeros(1. % Initialize Y matrix % % convolution with succesive blocks for m = 0:M-1 xm = [x(m*L+1:(m+1)*L).*H.h. −1} n = 0:4000-1.N).:) = real(ifft(fft(xm. y1 = ovrlpadd(x.6342e-016 2006 . Y1 = Y(:. Y1 = Y1’.M*L-Lx)]. % M = ceil(Lx/L).Y(1:M.7756e-017 e2 = 3. y = y1+y2. N = 2^ceil(log2(2*L-1)).Solutions Manual for DSP using Matlab (2nd Edition) 244 % % % % % % -------------------------------------------------[y] = hsolpadd(x. 0. 0. 4. 1. the minimum value of N to make the circular convolution equal to the linear convolution is 7.33 Given the sequences x1 (n) and x2 (n) shown below: x1 (n) = {2. 0} N = 7 : x1 (n) 7jx2 (n) = {2. as expected. then the desired result can be achieved. . −1. 1. 1. In this case then N = 4 + 4 − 1 = 7. −2. −1. 0. −2}. −2} N = 8 : x1 (n) 8jx2 (n) = {2. The linear convolution: x1 (n) ∗ x2 (n) = {2. −1. x2 (n) = {1. 0. −2. 2. 2. −2. From the results of the above two parts. −1. 1. 1} 1. 2} . 3. If we make N equal to the length of the linear convolution which is equal to the length of x1 (n) plus the length of x2 (n) minus one. 1. 2. −2.2006 Solutions Manual for DSP using Matlab (2nd Edition) 245 P5. −1. Circular convolutions x1 (n) Njx2 (n): N = 4 : x1 (n) 4jx2 (n) = {0. 0} 2. 0. 2 2 0 ≤ k ≤ (N − 1) .Solutions Manual for DSP using Matlab (2nd Edition) 246 P5. Notice that x(n) contains exactly ℓ periods (or cycles) of the cosine waveform in N samples. 0<ℓ<N which is a real-valued sequence. 1. If ℓ = 0. 0 ≤ n ≤ N − 1 = A cos(2π ℓn/N )R N (n) 0. then the DFT X (k) is given by X (k) = N−1 X x(n) e n=0 = AN δ(k). i. X (k) = AN AN δ [k − ((ℓ)) N ] + δ [k − N + ((ℓ)) N ] . Consider the DFT X (k) of x(n) which is given by X (k) = N−1 X x(n) e − j 2π N kn n=0 = N−1 X n=0  2π ℓn A cos N N−1 o A X n j 2π ℓn 2π 2π = e N + e− j N ℓn e− j N kn . 0≤k ≤ N −1 0 ≤ k ≤ (N − 1) 3. If ℓ < 0 or ℓ > N . − j 2π N kn = N−1 X A e− j n=0 2π N kn . elsewhere where ℓ is an integer. This is a windowed cosine sequence containing no leakage. then we must replace it by ((ℓ)) N in the result of part 1. 2 n=0 = =  e− j 2π N kn . 2 2 0 ≤k ≤ N −1 0 ≤ k ≤ (N − 1) . 2 n=0 2 n=0 AN AN δ (k − ℓ) + δ (k − N + ℓ) ..e.34 Let x(n) =  2006 A cos(2π ℓn/N ). 0≤k ≤ N −1 0≤k ≤ N −1 N−1 N−1 A X − j 2π (k−ℓ)n A X − j 2π (k+ℓ)n e N + e N . 2. set(Hf_1.’r’.x1.N-l]. set(H_s1. Sequence: x1(n) 4 Amplitude 2 0 −2 −4 0 20 40 60 80 100 n 120 140 160 180 200 DFT: X1(k) Amplitude 300 0 04 196 k Figure 5.’paperunits’.4]).’inches’. and 3..N. axis([-1..’markersize’. subplot(2.24.’NumberTitle’.[1.2006 Solutions Manual for DSP using Matlab (2nd Edition) 247 4.04*pi*n).’inches’.0. X1 = real(fft(x1.6. xlabel(’\itk’). l = 4. subplot(2. n = 0:N-1.10).1. Verification of the results of parts 1.’fontsize’.1). axis([-1.34. ylabel(’Amplitude’).-10.-4.4]. ylabel(’Amplitude’).2). ’color’.0.2).’position’.4]).’P5.1).[0.[0. x1 = 3*cos(0.04π n)R200 (n): N = 200.300]) The sequence x1 (n) and its DFT X 1 (k) are shown in Figure 5.’filled’).’markersize’. set(gca. xlabel(’\itn’).24: The signal x1 (n) and its DFT X 1 (k) in Problem P5. set(H_s2. title(’Sequence: {\itx}_1({\itn})’. H_s2 = stem(n.[0.X1.’off’.N)).6.’g’. k = 0:N-1.N.1. above using Matlab and the following sequences: (a) x1 (n) = 3 cos(0.. Hf_1 = figure(’Units’.10).310]).’filled’)..’xtick’.4(a)’).34.l.’Name’..1.’fontsize’.4(a) .0].’paperposition’. title(’DFT: {\itX}_1({\itk})’. 2. H_s1 = stem(n.[0.’ytick’. [0. title(’Sequence: {\itx}_2({\itn})’.’xtick’. set(gca.X2.[1.34.. set(Hf_2.’inches’.2).6.’g’.N-1]. Sequence: x2(n) Amplitude 6 4 2 0 0 5 10 15 20 25 n 30 35 40 45 50 DFT: X2(k) Amplitude 250 0 0 49 k Figure 5.’paperunits’.’markersize’.0.4(b) ..-1. H_s1 = stem(n.x2.1.’filled’).34.4]).1.’fontsize’. axis([-1.N. subplot(2. n = 0:N-1.’off’.[0.N.’position’.1). title(’DFT: {\itX}_2({\itk})’.10).25: The signal x2 (n) and its DFT X 2 (k) in Problem P5.2).0].10)..6. k = 0:N-1. X2 = real(fft(x2.’NumberTitle’. H_s2 = stem(n.N)).260]).-10. ’color’.250]) The sequence x2 (n) and its DFT X 2 (k) are shown in Figure 5.’markersize’.25. xlabel(’\itk’). subplot(2. l = 0. x2 = 5*cos(0*pi*n).1.2).[0.’filled’).’fontsize’.’inches’. xlabel(’\itn’). set(H_s1. ylabel(’Amplitude’).’r’. set(H_s2.’P5.4].’Name’.’paperposition’.Solutions Manual for DSP using Matlab (2nd Edition) 248 2006 (b) x2 (n) = 5R50 (n): N = 50.6]). axis([-1.[0.0. ylabel(’Amplitude’).’ytick’. Hf_2 = figure(’Units’.4(b)’). 5*pi*n)+cos(pi*n).’xtick’.2).N.’markersize’.2006 Solutions Manual for DSP using Matlab (2nd Edition) 249 (c) x3 (n) = [1 + 2 cos(0. n = 0:N-1. title(’DFT: {\itX}_3({\itk})’.1.’inches’.’inches’.1..6.’fontsize’.4].[0.34.’filled’).N)). ylabel(’Amplitude’).’Name’.’paperposition’.x3.26.34.10). axis([-1.’r’.N. set(H_s2.’markersize’.l3.’NumberTitle’.’fontsize’.1. x3 = 1+2*cos(0. subplot(2.’g’.10). xlabel(’\itn’). l2 = 25.-10.[1. l1 = 0.5π n) + cos(π n)]R100 (n): N = 100.’off’.[0.’P5.-1. X3 = real(fft(x3.[l1.N-l2.’ytick’.0. ylabel(’Amplitude’).26: The signal x3 (n) and its DFT X 3 (k) in Problem P5. set(H_s1.110]).4(c) 99 .’paperunits’. subplot(2.l2.N-1].6.1).[0.100]) The sequence x3 (n) and its DFT X 3 (k) are shown in Figure 5. set(gca..’position’. ’color’.0.’filled’). axis([-1.5])..0].X3.2). Sequence: x3(n) 5 Amplitude 4 3 2 1 0 −1 0 10 20 30 40 50 n 60 70 80 90 100 DFT: X3(k) Amplitude 100 0 0 25 50 k 75 Figure 5. H_s1 = stem(n. H_s2 = stem(n. xlabel(’\itk’). k = 0:N-1. l3 = 50.2).4]). title(’Sequence: {\itx}_3({\itn})’.4(c)’). set(Hf_3. Hf_3 = figure(’Units’. 2).2).’Name’.-1.6. ylabel(’Amplitude’).1. l = 50.Solutions Manual for DSP using Matlab (2nd Edition) 250 2006 (d) x4 (n) = cos(25π n/16)R64 (n): N = 64..N. x4 = cos(25*pi*n/16).1]).’g’.1.N-1].0. H_s2 = stem(n.-5.’position’.N)).N. Sequence: x4(n) Amplitude 1 0. title(’Sequence: {\itx}_4({\itn})’.’inches’.1). xlabel(’\itn’).’inches’..1. Hf_4 = figure(’Units’. X4 = real(fft(x4. H_s1 = stem(n.10).0].[0. set(H_s1.34.’ytick’.35]). xlabel(’\itk’).’xtick’.[0. ylabel(’Amplitude’). set(H_s2.X4.[1.. title(’DFT: {\itX}_4({\itk})’.’markersize’.l.’NumberTitle’. subplot(2.’fontsize’.[0.[0. subplot(2.4].’filled’).4(d) 63 .4]).’filled’).27.5 0 −0. n = 0:N-1.’off’.’P5.6. axis([-1.10).’paperposition’.’r’.’paperunits’.4(d)’).1.32]) The sequence x4 (n) and its DFT X 4 (k) are shown in Figure 5. ’color’.27: The signal x4 (n) and its DFT X 4 (k) in Problem P5.1.x4.’markersize’. set(gca.5 −1 0 10 20 30 40 50 60 n DFT: X4(k) Amplitude 32 0 0 14 50 k Figure 5. k = 0:N-1. set(Hf_4.2).N-l.34. axis([-1.’fontsize’.0. xlabel(’\itk’).0.20]) The sequence x5 (n) and its DFT X 5 (k) are shown in Figure 5.’NumberTitle’.34.4]). set(gca.4(e) 40 . H_s2 = stem(n.[0.10).[0.’inches’.1). ylabel(’Amplitude’). ylabel(’Amplitude’).9*pi*n).1.[0.2). Sequence: x5(n) Amplitude 1 0. H_s1 = stem(n.’fontsize’. n = 0:N-1. X5 = real(fft(x5. title(’DFT: {\itX}_5({\itk})’.’P5.’markersize’.4].4(e)’). axis([-1.N.’off’.1*pi*n)-3*cos(1.’markersize’.-5.’xtick’.2006 Solutions Manual for DSP using Matlab (2nd Edition) 251 (e) x5 (n) = [cos(0. subplot(2.X5.[1.’Name’.’paperunits’.0].’filled’).2).28: The sample plot of various signals in Problem P5.-1.[0. set(H_s1.l1..1.1]).’paperposition’.N].’filled’). xlabel(’\itn’).N)). l1 = 2. k = 0:N-1.6.l2. subplot(2.2)..9π n)]R40 (n): N = 40.’r’.25]).10). ’color’.N. Hf_5 = figure(’Units’.1π n) − 3 cos(1.’fontsize’.1. set(H_s2.5 −1 0 5 10 15 20 n 25 30 35 40 DFT: X5(k) Amplitude 20 0 0 2 38 k Figure 5. title(’Sequence: {\itx}_5({\itn})’. x5 = 4*cos(0.’ytick’.1.5 0 −0..x5.34. l2 = 38. axis([-1.28.’inches’.0.6.’position’.’g’.1. set(Hf_5. 5) (5. Consider N−1 X N−1 X      2π 2π X (k) = x(n)e =A cos(ω0 n) cos nk − j sin nk N N n=0 n=0     N−1 N−1 X X 2π 2π X R (k) + j X I (k) = A cos(ω0 n) cos nk − j A cos(ω0 n) sin nk N N n=0 n=0 −j  2π N  nk Hence N−1 X   2π X R (k) = A cos(ω0 n) cos nk N n=0   N−1 X 2π cos(ω0 n) sin nk X I (k) = −A N n=0 (5. consider N−1 X        N−1   N−1 2π 1 X j 2πN vn 1 X − j 2πN vn 1 1 − e j 2πv 1 1 − e− j 2πv vn = cos e + e = + N 2 n=0 2 n=0 2 1 − e j 2πN v 2 1 − e− j 2πN v n=0    1 j πn 1 − j πv N−1 sin(π v) N e + e 2 sin(π v/N ) 2   π v(N − 1) sin(π n) = cos N sin(π v/N ) =  N−1 N  sin(π v) sin(π v/N ) (5.7).8) in the first term of (5.7) with v = (k − f 0 N ) and in the second term of (5. 0 ≤ k < N (5.6) Consider the real-part in (5.8) Now substituting (5.7) 2 n=0 N N  To reduce the sum-of-cosine terms in (5. 1. we obtain the desired result   A π(N − 1) sin[π( f 0 N − k)] X R (k) = cos (k − f 0 N ) 2 N sin[ Nπ ( f 0 N − k)]   A π(N − 1) sin{π(k − [N − f 0 N ])} + cos (k − [N − f 0 N ]) (5.7) with v = (k − [N − f 0 N ]). where ω0 is a real number.35 Let x(n) = A cos(ω0 n)R N (n).9) 2 N sin[ Nπ ( f 0 N − k)] . X R (k) = = = = N−1 X      N−1  AX 2π 2π 2π nk = nk + cos ω0 n + nk A cos(ω0 n) cos cos ω0 n − N 2 n=0 N N n=0     N−1  AX 2π 2π cos 2π f 0 n − nk + cos 2π f0 n + nk [∵ ω0 = 2π f0 ] 2 n=0 N N     N−1  AX 2π 2π ( f 0 N − k)n + cos ( f 0 N + k)n cos 2 n=0 N N     N−1  2π 2π AX cos (k − f 0 N )n + cos {k − (N − f 0 N )}n .5).Solutions Manual for DSP using Matlab (2nd Edition) 252 2006 P5. 34.10) 2. Verification of the leakage property using x(n) = cos (5π n/99) R200 (n): The sequence x(n).35. and the imaginary part of its DFT X I (k) are shown in Figure 5.29.29: The leakage property of a cosine signal in Problem P5. we can show that o sin[π( f N − k)] n A 0 (k − f N ) sin π(N−1) 0 π N 2 sin[ N ( f 0 N − k)] o sin{π(k − [N − f N ])} n A 0 (k − [N − f N ]) − sin π(N−1) 0 π N 2 sin[ N ( f 0 N − k)] X I (k) = − (5. It is a natural result due to the fact that bandlimited periodic cosines are sampled over noninteger periods.1 do not apply. the real-part of its DFT X R (k). Due to this fact. Sequence: x(n) Amplitude 1 0. The above result implies that the original frequency ω0 of the cosine waveform has leaked into other frequencies that form the harmonics of the time-limited sequence and hence it is called the leakage property of cosines. the periodic extension of x(n) does not result in a continuation of the cosine waveform but has a jump at every N interval. 3.3 195 . This jump results in the leakage of one frequency into the abducent frequencies and hence the result of the Problem P5.5 −1 0 20 40 60 80 100 n 120 140 160 180 200 Real−part of the DFT: XR(k) Amplitude 100 0 −10 0 5 100 k 195 Imaginary−part of the DFT: XI(k) Amplitude 20 0 −20 0 5 100 k Figure 5.2006 Solutions Manual for DSP using Matlab (2nd Edition) 253 Similarly.5 0 −0. j 2 n=0 2 n=0 AN AN δ (k − ℓ) − δ(k − N + ℓ). x(n) e− j 2π N kn = N−1 X n=0 0 e− j 2π N kn . If ℓ < 0 or ℓ > N . i. j 2 n=0 = = e− j kn .. 2. Consider the DFT X (k) of x(n) which is given by X (k) = N−1 X x(n) e − j 2π N kn n=0 = N−1 X n=0  2π ℓn A sin N  N−1 o A X n j 2π ℓn 2π 2π = e N − e− j N ℓn e− j N kn .Solutions Manual for DSP using Matlab (2nd Edition) 254 P5. j2 j2 2π N 0≤k ≤ N −1 0 ≤ k ≤ (N − 1). 0<ℓ<N which is a purely imaginary-valued sequence. j2 j2 0 ≤ k ≤ (N − 1) . then we must replace it by ((ℓ)) N in the result of part 1. 0 ≤ k ≤ (N − 1) 0 ≤ k ≤ (N − 1) 3. elsewhere where ℓ is an integer. 0≤k ≤ N −1 0≤k ≤ N −1 N−1 N−1 A X − j 2π (k−ℓ)n A X − j 2π (k+ℓ)n e N − e N . If ℓ = 0. 1. then the DFT X (k) is given by X (k) = N−1 X n=0 = 0.36 Let x(n) =  2006 A sin(2π ℓn/N ). X (k) = AN AN δ [k − ((ℓ)) N ] − δ [k − N + ((ℓ)) N ] . Notice that x(n) contains exactly ℓ periods (or cycles) of the sine waveform in N samples.e. 0 ≤ n ≤ N − 1 = A sin(2π ℓn/N )R N (n) 0. This is a windowed sine sequence containing no leakage. x1 = 3*sin(0.’Name’.’markersize’.’g’.-350.0.N-l]. axis([-1.1. above using Matlab and the following sequences: (a) x1 (n) = 3 sin(0.300]) The sequence x1 (n) and its DFT X 1 (k) are shown in Figure 5.1). title(’Sequence: {\itx}_1({\itn})’.’inches’.2006 Solutions Manual for DSP using Matlab (2nd Edition) 255 4.. Verification of the results of parts 1. subplot(2.N)).2). 2..’fontsize’.6. X1 = imag(fft(x1. ylabel(’Amplitude’). set(Hf_1.’filled’). set(H_s1.04*pi*n).’xtick’.’position’.’P5.’r’.’ytick’.[-300.0. and 3. l = 4.30.[1. set(H_s2. subplot(2.10). n = 0:N-1.[0. ’color’. k = 0:N-1.[0.4]). xlabel(’\itk’).N.4]). xlabel(’\itn’). Hf_1 = figure(’Units’.0].1.’inches’.4]...6(a) .’markersize’. title(’DFT: {\itX}_1({\itk})’.10).[0.04π n)R200 (n): N = 200.1.l. set(gca.’NumberTitle’.2).N.34.x1. H_s2 = stem(n.1).’paperunits’..-4. ylabel(’Amplitude’). H_s1 = stem(n.350]). axis([-1. Sequence: x1(n) 4 Amplitude 2 0 −2 −4 0 20 40 60 80 100 n 120 140 160 180 200 DFT: X1(k) Amplitude 300 0 −300 04 196 k Figure 5.’filled’).30: The signal x1 (n) and its DFT X 1 (k) in Problem P5.4(a)’).X1.’paperposition’.36.6.0.’fontsize’.’off’. 34.4]. x2 = 5*sin(10*pi*n).4]). set(H_s2.’P5.4(b)’)..’markersize’. n = 0:N-1.’r’.X2.1). ’color’.’xtick’. set(Hf_2.5 −1 0 5 10 15 20 25 n 30 35 40 45 50 DFT: X2(k) Amplitude 1 0 −1 0 49 k Figure 5.2). title(’DFT: {\itX}_2({\itk})’.’inches’.31: The signal x1 (n) and its DFT X 1 (k) in Problem P5.’fontsize’.’Name’..’filled’).1.N. Sequence: x2(n) 1 Amplitude 0.6. set(gca.1. axis([-1.[0.1.’position’. subplot(2.10).[-1.-1. title(’Sequence: {\itx}_2({\itn})’.[0.N-1].’fontsize’.34.’off’.[0.-1.10). ylabel(’Amplitude’). k = 0:N-1. set(H_s1.Solutions Manual for DSP using Matlab (2nd Edition) 256 2006 (b) x2 (n) = 5 sin(10π n)R50 (n): N = 50.’ytick’.0]. ylabel(’Amplitude’).0.5 0 −0.0. H_s1 = stem(n.6(b) .2).1]).N)). l = 0. X2 = imag(fft(x2.2).’g’.[1.’markersize’.1]) The sequence x1 (n) and its DFT X 1 (k) are shown in Figure 5. subplot(2.6.0.’paperunits’.’inches’..’paperposition’.1]).’NumberTitle’.x2. Hf_2 = figure(’Units’.’filled’). axis([-1. H_s2 = stem(n.N. xlabel(’\itk’). xlabel(’\itn’).31. set(H_s1.0]. x3 = 2*sin(0.0.1.’g’.l3.’fontsize’.6.34. xlabel(’\itn’).34.1.X3. l2 = 25.5π n) + sin(π n)]R100 (n): N = 100.N-1].10). title(’DFT: {\itX}_3({\itk})’.’paperposition’. subplot(2. ylabel(’Amplitude’).’position’.l2.-3.’paperunits’..’r’.2).’off’.N. X3 = imag(fft(x3. H_s2 = stem(n. ’color’.’xtick’.100]) The sequence x1 (n) and its DFT X 1 (k) are shown in Figure 5. subplot(2.’Name’. n = 0:N-1. l1 = 0. set(H_s2.6.4(c)’).N-l2.4]). l3 = 50.6(c) 99 .’ytick’. Hf_3 = figure(’Units’.’markersize’.N.2).[l1. axis([-1.’NumberTitle’.[0.’inches’.32: The signal x1 (n) and its DFT X 1 (k) in Problem P5.N)).0.-120. k = 0:N-1.[1.1). set(gca. xlabel(’\itk’).[0.’P5.2).’filled’).3]).32.2006 Solutions Manual for DSP using Matlab (2nd Edition) 257 (c) x3 (n) = [2 sin(0. set(Hf_3.[-100.’filled’). title(’Sequence: {\itx}_3({\itn})’..10). axis([-1. ylabel(’Amplitude’).4].’fontsize’. Sequence: x3(n) 3 Amplitude 2 1 0 −1 −2 −3 0 10 20 30 40 50 n 60 70 80 90 100 DFT: X3(k) Amplitude 100 0 −100 0 25 50 k 75 Figure 5.’markersize’.120]).5*pi*n)+0*sin(pi*n).x3.0..1. H_s1 = stem(n.’inches’. 2)..1).N-1]. title(’Sequence: {\itx}_4({\itn})’.1]).’NumberTitle’.[0.1.’inches’. Sequence: x4(n) Amplitude 1 0.2).10). set(H_s1.6(d) 63 .1..’inches’.’g’. x4 = sin(25*pi*n/16).’fontsize’.4(d)’).’fontsize’.5 −1 0 10 20 30 40 50 60 n DFT: X4(k) Amplitude 32 0 −32 0 14 50 k Figure 5. axis([-1.’Name’.34.1.4]).[-32.10).6.33.N. set(Hf_4.’markersize’.1.[0.0.0.x4.’ytick’. xlabel(’\itn’).N-l. H_s2 = stem(n. X4 = imag(fft(x4.’P5. n = 0:N-1.’off’.0].-40. ylabel(’Amplitude’). xlabel(’\itk’). subplot(2. subplot(2.’paperunits’.N)). ’color’. ylabel(’Amplitude’).1. k = 0:N-1.0.5 0 −0.6. title(’DFT: {\itX}_4({\itk})’.Solutions Manual for DSP using Matlab (2nd Edition) 258 2006 (d) x4 (n) = sin(25π n/16)R64 (n): N = 64.33: The signal x1 (n) and its DFT X 1 (k) in Problem P5.’filled’).34.N. Hf_4 = figure(’Units’.’xtick’.-1.40]).4].’markersize’.2).32]) The sequence x1 (n) and its DFT X 1 (k) are shown in Figure 5. l = 50.. set(H_s2.’paperposition’.[0.’r’.[1. set(gca.’position’.X4.’filled’). axis([-1.l. H_s1 = stem(n. l1 = 1.0.’r’.’inches’.1π n) − 3 sin(1.34.[0. set(Hf_5.0. set(H_s1.N. ylabel(’Amplitude’). H_s2 = stem(n.70]) The sequence x1 (n) and its DFT X 1 (k) are shown in Figure 5.’markersize’.0].x5.9π n)]R20 (n): N = 20.1*pi*n)-3*sin(1.’markersize’.4(e)’). H_s1 = stem(n.’paperunits’. subplot(2.’filled’).’P5.’fontsize’.[0.[0.1.6. set(gca.[-70.-80.’position’.80]). Sequence: x5(n) 10 Amplitude 5 0 −5 −10 0 2 4 6 8 10 12 14 16 18 20 n DFT: X5(k) Amplitude 70 0 −70 0 1 19 k Figure 5. x5 = 4*sin(0.N].2)..10).N.34. xlabel(’\itn’). title(’Sequence: {\itx}_5({\itn})’..-10. title(’DFT: {\itX}_5({\itk})’.’Name’.4]. l2 = 19. k = 0:N-1.2). ’color’.’filled’).[1. X5 = imag(fft(x5.2006 Solutions Manual for DSP using Matlab (2nd Edition) 259 (e) x5 (n) = [4 sin(0.6(e) 20 .9*pi*n).X5. ylabel(’Amplitude’).1.’g’.34: The signal x1 (n) and its DFT X 1 (k) in Problem P5.’ytick’.2).6.’off’.’paperposition’.4]). subplot(2.’fontsize’. n = 0:N-1.10]).1.34.’inches’. set(H_s2. xlabel(’\itk’). Hf_5 = figure(’Units’.’xtick’.’NumberTitle’.0.l1.1).N)). axis([-1.l2.. axis([-1.10). 11) (5. X R (k) = = = = N−1 X      N−1  AX 2π 2π 2π nk = nk + sin ω0 n + nk A sin(ω0 n) cos sin ω0 n − N 2 n=0 N N n=0     N−1  AX 2π 2π sin 2π f0 n − nk + sin 2π f 0 n + nk [∵ ω0 = 2π f 0 ] 2 n=0 N N     N−1  AX 2π 2π ( f 0 N − k)n + sin ( f 0 N + k)n sin 2 n=0 N N     N−1  2π 2π AX − sin (k − f 0 N )n + sin {k − (N − f 0 N )}n .13) with v = (k − f 0 N ) and in the second term of (5.13) with v = (k − [N − f 0 N ]).12) Consider the real-part in (5.14) in the first term of (5.14) Now substituting (5.Solutions Manual for DSP using Matlab (2nd Edition) 260 2006 P5.37 Let x(n) = A sin(ω0 n)R N (n). where ω0 is a real number.13). 0 ≤ k < N (5. 1. consider N−1 X        N−1   N−1 2π 1 X j 2πN vn 1 X − j 2πN vn 1 1 − e j 2πv 1 1 − e− j 2πv vn = sin e − e = − N j 2 n=0 j 2 n=0 j 2 1 − e j 2πN v j 2 1 − e− j 2πN v n=0    1 − j πn 1 j πv N−1 sin(π v) N e − e j2 sin(π v/N ) j2   π v(N − 1) sin(π v) = sin N sin(π v/N ) =  N−1 N  sin(π v) sin(π v/N ) (5.13) 2 n=0 N N  To reduce the sum-of-sine terms in (5. we obtain the desired result   A π(N − 1) sin[π( f 0 N − k)] X R (k) = − sin (k − f 0 N ) 2 N sin[ Nπ ( f 0 N − k)]   A π(N − 1) sin{π(k − [N − f 0 N ])} + sin (k − [N − f 0 N ]) (5. Consider N−1 X N−1 X      2π 2π X (k) = x(n)e =A sin(ω0 n) cos nk − j sin nk N N n=0 n=0     N−1 N−1 X X 2π 2π X R (k) + j X I (k) = A sin(ω0 n) cos nk − j A sin(ω0 n) sin nk N N n=0 n=0 −j  2π N  nk Hence N−1 X   2π X R (k) = A sin(ω0 n) cos nk N n=0   N−1 X 2π sin(ω0 n) sin nk X I (k) = −A N n=0 (5.15) 2 N sin{ Nπ ( f 0 N − k)} .11). It is a natural result due to the fact that bandlimited periodic sines are sampled over noninteger periods. Sequence: x(n) Amplitude 1 0. the periodic extension of x(n) does not result in a continuation of the sine waveform but has a jump at every N interval.35: The leakage property of a sine signal in Problem P5.37.5 −1 0 10 20 30 40 50 n 60 70 80 90 100 Real−part of the DFT: XR(k) Amplitude 50 −50 0 5 50 k 95 Imaginary−part of the DFT: XI(k) Amplitude 5 0 −5 0 5 50 k Figure 5. This jump results in the leakage of one frequency into the abducent frequencies and hence the result of the Problem P5.2006 Solutions Manual for DSP using Matlab (2nd Edition) 261 Similarly. Verification of the leakage property using x(n) = sin(5π n/99)R100 (n): The sequence x(n).5 0 −0.16) 2.1 do not apply. It implies that the original frequency ω0 of the sine waveform has leaked into other frequencies that form the harmonics of the time-limited sequence. 3.35.3 95 . we can show that   π(N − 1) A sin[π( f 0 N − k)] X I (k) = − sin (k − f 0 N ) 2 N sin[ Nπ ( f 0 N − k)]   A π(N − 1) sin{π(k − [N − f 0 N ])} + sin (k − [N − f 0 N ]) 2 N sin[ Nπ ( f 0 N − k)] (5. Due to this fact. the real-part of its DFT X R (k).36. and the imaginary part of its DFT X I (k) are shown in Figure 5. The above result is the leakage property of sines. 5 k 97 Figure 5. N = 99 provides almost complete cycles of both the sine and the cosine components.5 95 99 Imaginary Part of the DFT: XI(k) Amplitude 100 0 −100 02 49. . . Out of the given three values. Out of the given three values.Solutions Manual for DSP using Matlab (2nd Edition) 262 2006 P5.36. Thus N = 50 provides the most accurate estimate as shown in Figure 5.38 An analog signal xa (t) = 2 sin(4π t) + 5 cos(8π t) is sampled at t = 0.2 .1 2.01n for n = 0.38. 1.36: The accurate spectrum of the signal in Problem P5. . Real Part of the DFT: XR(k) Amplitude 150 0 −40 0 2 25 48 50 Imaginary Part of the DFT: XI(k) Amplitude 60 0 −60 01 25 k 49 Figure 5.37. 1. .37: The least amount of leakage in the spectrum of the signal in Problem P5. Real Part of the DFT: XR(k) Amplitude 300 0 −30 0 4 49. N − 1 to obtain an N -point sequence x(n). Thus N = 99 provides the least amount of leakage as shown in Figure 5. An N -point DFT is used to obtain an estimate of the magnitude spectrum of xa (t).38. N = 50 provides complete cycles of both the sine and the cosine components. P5. 2. Compare the above approaches in terms of the convolution results and their execution times. Using this approach. 3. 1] for 0 ≤ n ≤ 106 . determine and draw the signal flow graph for the N = 16 point. determine and draw the signal flow graph for the N = 8 point. determine the output sequence y(n) = x(n) ∗ h(n).40 Using (5. 0 ≤ n ≤ 15. 0 ≤ n ≤ 7. and 4096. Using this flow graph. determine y(n) with FFT sizes of 1024.41 Let x(n) be a uniformly distributed random number between [−1.2006 Solutions Manual for DSP using Matlab (2nd Edition) 263 P5.4π n). radix-4 decimation-in-time FFT algorithm.49). . 0 ≤ n ≤ 100 1. Using the conv function. P5.49). determine the DFT of the sequence x(n) = cos (π n/2) . Using this flow graph determine the DFT of the sequence x(n) = cos (π n/2) . Let h(n) = sin(0. 2048.39 Using (5. Consider the overlap-and-save method of block convolution along with the FFT algorithm to implement high-speed block convolution. radix-2 decimation-in-frequency FFT algorithm. 264 Solutions Manual for DSP using Matlab (2nd Edition) 2006 . y(n) = x(n) + 2x(n − 1) + 3x(n − 2): 1 x(n) y(n) z−1 2 z−1 3 2.53 z−1 0.1 Direct form I block diagrams.648 265 . 1.7 z−1 −1.53z −2 − 0.648z −3 1 x(n) y(n) −1 z 1.7z −1 1 : + 1. H (z) = 1− 1.Chapter 6 Digital Filter Structures P6. 7y(n − 1) − 1.2 z−1 z−1 2 0. H (z) = 0.576y(n − 3) + x(n): 1 x(n) y(n) z−1 1.6 z−1 z−1 1 5.14z −2 + 0. y(n) = 1.36y(n − 2) + 0. y(n) = 1.36 z−1 0.6y(n − 1) + 0.576 4.64 1 − 3z −1 + 3z −2 + z −3 : 1 + 0.Solutions Manual for DSP using Matlab (2nd Edition) 266 3.14 z−1 z−1 1 −0.64y(n − 2) + x(n) + 2x(n − 1) + x(n − 2): 1 x(n) y(n) z−1 z−1 2 1.44 2006 .7 z−1 −1.2z −1 − 0.44z −3 1 x(n) y(n) −1 −1 z z −3 −0. 2z −2  y(n) = 0.5 + 2z −1 + z −2 W (z) w(n) = K x(n) + 1.2) .5w(n) + 2w(n − 1) + w(n − 2) ⇒ Y (z) = 0.8z −1 + 0.8z −1 + 0.1).2z −2 (i) The given structure is canonical (ii) The given structure is not canonical.2 Consider the following two block diagrams: z-1 2 2 x(n) K w(n) y(n) x(n) w(n) K 0.5 K y(n) z1 2 1.9 3. Canonical structure: Y (z) 0.5 + 2z −1 + z −2 =K X (z) 1 − 0.5 -0. The system function H (z) = Y (z)/ X (z): (i) Referring to signal nodes in the above figure (i): w(n) = K x(n) + 12 y(n − 1) y(n) = w(n) + 2w(n − 1) = K x(n) + 21 y(n − 1) + 2K x(n − 1) + 2 21 y(n − 2) = K x(n) + 2K x(n − 1) + 12 y(n − 1) + y(n − 2) Hence H (z) = K 1 + 2z −1 1 − 12 z −1 − z −2 (6.9 z-1 z-1 z -1 0.2006 Solutions Manual for DSP using Matlab (2nd Edition) 267 P6. H (1) = 1 = K 1−1+2 = −6K ⇒ K = − 16 . The canonical structure is x(n) 0.1) (ii) Referring to signal nodes in the above figure (ii): X (z) 1 − 0.8w(n − 1) − 0.8 z −0.5 z -1 y(n) 1. Value of K so that H (e j 0 ) = 1: 1 1 (i) From (6.9w(n − 2) ⇒ W (z) = K Hence H (z) = 2. 1 −1 2 (6.8 z-1 (ii) (i) 1. Transposed block diagram: The block diagram due to steps (i) and (ii) is shown below.9 = 35K ⇒ K = − 35 . w(n) b x(n) y(n) a z-1 (b) 3.3). . Block diagram of the above system with input node x(n) and output node y(n) is shown below. x(n) b y(n) a z-1 (a) 2. H (1) = 1 = K 1−1.3 Consider the LTI system described by y(n) = a y(n − 1) + b x(n) (6.3) 1. Difference equation representation of the transposed structure in part 2 above: Referring to the nodes in the transposed structure above w(n) = x(n) + a w(n − 1) ⇒ W (z) = 1 X (z) 1 − az −1 and y(n) = b w(n) ⇒ Y (z) = b W (z) or  Y (z) 1 − az −1 = b X (z) ⇒ y(n) = b x(n) + a y(n − 1) which is the same equation as (6.Solutions Manual for DSP using Matlab (2nd Edition) 268 2006 0.2). y(n) b x(n) a z-1 (i) and (ii) The final block diagram after redrawing is shown below.8+0.5+2+1 1 (ii) From (6. P6. .818 2.818 y(n) −2.536 −2.656 1 z z−1 z−1 z−1 2. 1 x(n) y(n) −1 −1 z −2.215z −2 − 2.536 −3. Clearly it looks similar to that in part 1. The transposed direct form I structure block diagram is shown above on the right.536z −1 + 3.656 Clearly it looks similar to that in part 2.215 z−1 −2.6560z −4 (6.97z −2 − 2.536 z−1 3.818 −0.818z −1 + 3.97 3.818 z−1 2.97 −3.054 −2. 3.818 −3.4) 1.4 Consider the LTI system given by H (z) = 1 − 2. 1 x(n) 2.656 1 x(n) −1 z z z−1 z−1 z−1 z−1 z−1 z−1 y(n) −1 2.054 −0.054 z−1 1 1 −0. The normal direct form II structure block diagram is shown below on the left.2006 Solutions Manual for DSP using Matlab (2nd Edition) 269 P6. The normal direct form I structure block diagram is shown below on the left.818 2.054z −3 + 0.215 2.656 y(n) −2. 4.215 3.054 1 −0.8180z −3 + z −4 1 − 2.818 z−1 1 z−1 z−1 z−1 x(n) −2.818 2.97 −3.536 z−1 3. The transposed direct form II structure block diagram is shown above on the right.97 2.215 z−1 z−1 −2. 3807 0.285 1.-2.8099 1.97.97z −2 − 2.5326 1.1].0.2854 1.3.054.3.-2.215.0000 -1.0000 -1.0000 -1.8180z −3 + z −4 1 − 2. A cascade structure containing second-order normal direct from II sections: Matlab script: b = [1.818.3.8100 1 x(n) 1 1 z−1 −1.8099 y(n) −1 −1.1553 0.97. [b0.5326 1.3.a) b0 = 1 B = 1.1].155 z−1 −1.656].533 z−1 1 −0.054z −3 + 0.3807 0.285 1.B.-2.0000 -1.054.8100 1 1 x(n) 1 −1 z 1.0000 -1.A] = dir2cas(b.8099 1.0000 1.656].0000 A = 1.536.270 Solutions Manual for DSP using Matlab (2nd Edition) 2006 P6.536.0000 -1. A cascade structure containing second-order transposed direct from II sections: Matlab script: b = [1.A] = dir2cas(b. [b0.0000 -1. a = [1.818z −1 + 3.81 .a) b0 = 1 B = 1.536z −1 + 3. a = [1.-2.215z −2 − 2.1553 0.0000 A = 1.533 z−1 1 −0.81 1 2.0.155 z −1.5 Consider the LTI system given by H (z) = 1 − 2.0000 1.2854 1.381 z−1 1 −0.0000 -1.215.-2.818.818.-2.381 z−1 −0.818.8099 y(n) 1.6560z −4 1.-2.-2.B. 5244 B = -0.818.a) C = 1.3807 0.2644 z−1 −0.81 4.155 0. [C.8100 1.-2. a = [1.2006 Solutions Manual for DSP using Matlab (2nd Edition) 271 3.2644 -0.-2.A] = dir2par(b. [C.-2.3.2460 0.-2.8099 −0.656].818.054.2460 0.215.5244 B = -0.8100 1.1222 1.1].97.155 −0.818.0000 -1.1222 z−1 −0.-2.656]. a = [1.97.215.536.-2.8099 1.524 y(n) −0.1553 0.2644 1.3.81 .818.0000 -1.536.-2.2783 0.B.2644 -0.-2.381 −0.1222 A = 1.a) C = 1.2783 −1 z 0.1222 A = 1.3.246 −1 z 0.0000 -1.8099 1.0.1].246 −1 z 1.3. A parallel structure containing second-order transposed direct from II sections: Matlab script: x(n) b = [1.2783 0.B.0.8099 −0.3807 0.381 0. A parallel structure containing second-order normal direct from II sections: Matlab script: x(n) b = [1.2783 −1 z 1.054.0000 -1.1553 0.524 y(n) −0.A] = dir2par(b. x).6 A causal linear time-invariant system is described by y(n) = 4 X k=0 cos(0. Matlab script: z−1 z−1 z−1 z−1 z−1 0 ≤ n ≤ 50 n = 0:50.^n.’g’.1*pi*[1:5])]. a = [1.’normal’) Output Sequence y(n) 4 3.^[1:5]).272 Solutions Manual for DSP using Matlab (2nd Edition) 2006 P6.4]). 1 x(n) y(n) z−1 0.3).1π k)x(n − k) − 5 X k=1 (0.2472 z−1 0.9511 −0. y = filter(b. set(H_stem.5878 −0.-1.3277 Response of the system to   x(n) = 1 + 2(−1)n .’fontname’.’filled’).5 0 −0. axis([-1.5 −1 0 5 10 15 20 25 30 35 40 45 50 .51.1π k)y(n − k) 1.3762 z−1 0.309 −0.8).a. title(’Output Sequence {\ity}({\itn})’.5 1 0.y.5 2 1. H_stem = stem(n.3896 −0.809 −0.’markersize’.’times’.*sin(0.4142 z−1 0.’fontweight’.1*pi*[0:4]).8)k sin(0. x = 1 + 2*(-1).5 3 2.((0. Normal direct form I: Matlab script: b = cos(0. 809 z −0.3762 −1 0.^n.1*pi*[1:5])].9511 y(n) z−1 −0.5 2 1.’g’.4142 −1 0.’fontweight’.’filled’).1*pi*[0:4]).-1. x = 1 + 2*(-1).309 z −0.y. Transposed direct form II: Matlab script: b = cos(0. H_stem = stem(n.5 0 −0. a = [1. Matlab script: 0 ≤ n ≤ 50 n = 0:50.2472 −1 0. title(’Output Sequence {\ity}({\itn})’.8).’normal’) Output Sequence y(n) 4 3.’markersize’.5 1 0.5878 z −0.4]).5 −1 0 5 10 15 20 25 30 35 40 45 50 .2006 Solutions Manual for DSP using Matlab (2nd Edition) 273 2.((0.’fontname’.3277 Response of the system to   x(n) = 1 + 2(−1)n .x).51.3896 −0.5 3 2. 1 x(n) 0. axis([-1.3).^[1:5]).a. y = filter(b.*sin(0.’times’. set(H_stem. 5 1 0.5969   x(n) = 1 + 2(−1)n .A] = dir2cas(b.5969 1.A.5177 1.3).’fontname’.0844 0.205 1.7159 z−1 0.8238 0 z−1 0.-1.^n. y = casfiltr(b0.0000 -1.’filled’). x = 1 + 2*(-1).*sin(0. Cascade form containing second-order normal direct form II sections: Matlab script: b = cos(0.2047 0.6158 0.0000 1. title(’Output Sequence {\ity}({\itn})’.B.B.1*pi*[0:4]). set(H_stem.’g’.0000 0.084 Response of the system to −0.8238 1.Solutions Manual for DSP using Matlab (2nd Edition) 274 2006 3.’times’.’markersize’. a = [1. Matlab script: −0.5556 1 0 0 0 ≤ n ≤ 50 n = 0:50.5556 1.2537 z−1 −0.x).2537 0.’fontweight’.((0. axis([-1.0000 0.y.8).0000 -0. [b0.5 −1 0 5 10 15 20 25 30 35 40 45 50 .5 2 1.4]).a) b0 = 1 B = 1. H_stem = stem(n.5 3 2.5177 y(n) z−1 −0.1*pi*[1:5])].0000 0 0 A = 1.’normal’) Output Sequence y(n) 4 3.^[1:5]).7159 0 1 1 x(n) 1 z−1 −0.5 0 −0.51.6158 z−1 1. ’fontname’.’normal’) .4]).1634 −0.1634 0 A = 1. sin(0. 0 ≤ n ≤ 50 x(n) y(n) 0.084 −0.8238 1.a) C = [] B = 0. Parallel form containing second-order transposed direct form II sections: Matlab script: b = cos(0..3221 −1 z 0.^n.1*pi*[1:5])].1969 0.7159 0 Response of the system to   x(n) = 1 + 2(−1)n .B. [C. x = 1 + 2*(-1).’filled’).6158 0.’markersize’.5556 0.B. axis([-1.0000 0.A] = dir2par(b.2644 −0.’g’.5145 0.0844 0.3221 0.8).0000 -1.51.1969 1.2644 0. title(’Output Sequence {\ity}({\itn})’.A.((0.8238 0.’fontweight’. a = [1.1*pi*[0:4]).0000 0.5145 z−1 0.5556 1.2006 Solutions Manual for DSP using Matlab (2nd Edition) 275 4. H_stem = stem(n.y.7159 0 Matlab script: n = 0:50.. set(H_stem.3).x).^[1:5]).*.6158 −0.’times’.-1. y = parfiltr(C. 5 1 0.5 3 2.5 −1 0 5 10 15 20 25 30 35 40 45 50 .276 Solutions Manual for DSP using Matlab (2nd Edition) 2006 Output Sequence y(n) 4 3.5 2 1.5 0 −0. 0361 0. Lattice-ladder form: Matlab script: b = cos(0.7722 0.C.3457 0. set(H_stem.51.5 1 0.’times’.3090 0 x(n) −0.3176 0. title(’Output Sequence {\ity}({\itn})’.3176 0.5464 0.3277 −0.3277 0.3457 −0.’markersize’.3277 C = 0. axis([-1.309 −1 −1 z z z 0. [K. H_stem = stem(n.8).2006 Solutions Manual for DSP using Matlab (2nd Edition) 277 5.3).-1.2141 −0.5 −1 0 5 10 15 20 25 30 35 40 45 50 .1*pi*[0:4]).5950 0.7126 0.x).a) K = -0. [y] = ladrfilt(K.’normal’) Output Sequence y(n) 4 3.595 y(n) Response of the system to   x(n) = 1 + 2(−1)n . a = [1.5464 0.1*pi*[1:5])].2141 0.0361 −1 −1 z 0 0.5 2 1.y.*sin(0.((0.’fontweight’. x = 1 + 2*(-1).5 3 2.2141 0. Matlab script: 0 ≤ n ≤ 50 n = 0:50.7126 0.’g’.3176 −0.C] = dir2ladr(b.3457 0.’filled’).^[1:5]).5 0 −0.^n.’fontname’.0361 0.4]).7722 −1 z 0. 65 5.a] = residuez(R. a2 = [1.5500 2.004 −3. b3 = [1. k = k1+k2+k3.0000 -3. k = k1+k2+k3.k) b = 5.k3] = residuez(b3.64]. a2 = [1. [R1.65 5.3888 5 x(n) z−1 1. [R2.46 −4.R2.-0.p3.0. a1 = [1.p2.0.k2] = residuez(b2.a3).-0.Solutions Manual for DSP using Matlab (2nd Edition) 278 2006 P6.05 1.6500 5.k) b = 5.p1.3888 z −1.6500 5.0.0. b2 = [2.-1].0500 -1. Normal direct form II: Matlab script: %% (a) Transposed Direct form-I % Given H(z) b1 = [2.k2] = residuez(b2.775 −1 z 0.75]. a1 = [1.0. [b.0000 -1.05 z−1 1.75].7355 1. R = [R1.R3].p2.2610 2.4600 -4.0044 -0.2610 2.261 2.64z −2 1 − 0.8.1]. R = [R1.606 y(n) .46 −4.p1.p2.7748 -1.R2.75z −1 1 + 0.0.a2).736 −1.1].k1] = residuez(b1.k1] = residuez(b1.a1).55 z−1 −2. Transposed direct form I: Matlab script: %% (a) Transposed Direct form-I % Given H(z) b1 = [2.261 2.3888 2.-0.a] = residuez(R. [b.0500 -1.1].p3]. p = [p1.7355 1.8.7748 -1.606 z z−1 z−1 z−1 z−1 −3. p = [p1.0000 -3.8z −1 + 0.p.-0.p3.p3].64].7 An IIR filter is described by the following system function       1 + 0z −1 + z −2 2 − z −1 1 + 2z −1 + z −2 H (z) = 2 + + 1 − 0.k3] = residuez(b3.-1].0044 -0. [R2.6059 a = 1.0000 -1.0.736 z−1 −1.55 −2. [R1. a3 = [1.775 −1 0.004 −1 −1.81].a1).a2).1]. [R3. b2 = [2.81].0.6059 a = 1. b3 = [1.R3].4600 -4. a3 = [1.p.5500 2. [R3.a3).2.p2.81z −2 1.3888 y(n) z−1 z−1 z−1 z−1 5 x(n) 1.2. p2. b3 = [1.8000 0.6064 −0.1].4600 -4.5876 −1 −0.5424 0.0044 -0.8 y(n) −1 z z −0.6400 1.p1.0000 0.k) b = 5. k = k1+k2+k3.k3] = residuez(b3. R = [R1.5500 2.81 0.6064 1.R2.75 −1 z 0.0000 -0.0.64].0000 -0.a1).R3]. [R3.0000 -1.2.0000 0.p3.0000 -0.p2.8.0.k1] = residuez(b1.7748 -1. Cascade form containing transposed second-order direct form II sections: Matlab script: %% (c) Transposed Cascade form % Given H(z) b1 = [2. b2 = [2.p3].0500 [b0.2610 2. a2 = [1. [R1.75]. p = [p1.3888 a = 5 x(n) 1 1 −1 −1 z 0.6059 1.A] = dir2cas(b.7500 0 -1.6848 0.7355 1.2006 Solutions Manual for DSP using Matlab (2nd Edition) 279 3.5424 0 −0.1].a) b0 = 5 B = 1.81].B.k2] = residuez(b2.8100 1.5876 0.-0.a] = residuez(R.64 0 . [R2.0000 -3.0.7734 1. [b. a3 = [1.-1].6848 0 A = 1.a3).a2). a1 = [1.-0.p.0000 -0.0.7734 1 z 0.0000 -0.6500 5. b3 = [1.A] = dir2par(b. 4.75].0000 -1.0000 -0.3888 a = [C.0.0.1304 B = z−1 -0.64 0.k) b = 5. Parallel form containing normal second-order direct form II sections: Matlab script: %% (d) Normal Parallel form % Given H(z) b1 = [2.0000 -0.6667 2.k2] = residuez(b2.p3.0000 1.R3].R2.0000 -3.0500 -1.-0.a1).6400 0 −0.a).8 1. [R1.2346 4.13 x(n) y(n) C = −0.0.a3).0000 1.a2).4375 z−1 0. [R3.2610 2.k1] = residuez(b1. p = [p1.64]. a2 = [1.25 z−1 −0.p1. b2 = [2.k3] = residuez(b3.81 0.5500 2.7748 -1.p2.1].6500 5. a3 = [1.7355 1.8.81].Solutions Manual for DSP using Matlab (2nd Edition) 280 2006 4. [b.-0.2346 0.a] = residuez(R.2500 0 1.0000 1.4375 0.1].8100 0.75 0 z−1 0 .p.p2.7500 0 2 z−1 A = 0.0. a1 = [1.4600 -4.6667 z−1 0. [R2.B.-1].p3].0044 -0.8000 -0.6059 1.2. R = [R1. k = k1+k2+k3. a1).75].p3.k2] = residuez(b2.2. [R3. [K.p3].0.3888 0.3933 0. k = k1+k2+k3.k1] = residuez(b1.0. a3 = [1.776 y(n) .5916 0.7034 C = 2.1].C] = dir2ladr(b. p = [p1.a) K = -0.-1].-0.4733 -0.a] = residuez(R. a2 = [1.-0.8.64].p1.7034 −0.606 −1 z z 0.R3].6059 0. [R2.R2.k).3888 −0. b2 = [2.0.a3).2006 Solutions Manual for DSP using Matlab (2nd Edition) 281 5.7756 -0. [R1.4733 0.k3] = residuez(b3.5916 0.p.3933 −0.0.p2.a2).1].3933 −1 −1.0253 −1 z 2.81].5916 −0.7034 0.3888 1. [b. R = [R1.582 −1 z −0.5787 0. b3 = [1.5787 −1 z 1.4733 −0.2857 −0.0253 x(n) -0.5817 -0. Lattice-ladder form: Matlab script: %% Lattice-Ladder form % Given H(z) b1 = [2. a1 = [1.p2.2857 -1. A] = dir2par(b4.279 −1 z −39.a4] = cas2dir(1. b3 = [1.b1].75. [C.67 2.0380 a = 9. [b.Solutions Manual for DSP using Matlab (2nd Edition) 282 2006 P6. B = [B. a2 = [1.82z −1 1 + 2z −1 + z −2 H (z) = + 3 −2 1 + 0.7101 0 1.81].a] = par2dir(C.b3].0.6666 -2.-12.4 −11.a3]).[b2.-7/8.1/2].81z −2 1 − 78 z −1 + 32 z 1 − z −1 + 12 z −2 1.3/32]. a1 = [1.a1]. a3 = [1.038 z .2.8750 2.3959 -11. b2 = [24.2325 7.26.75 − 12.0.82.1].6719 -39.[a2.9].5 + 26.8 An IIR filter is described by the following system function ! !  −14.B.5. Normal direct form I: Matlab script: %% (a) Normal Direct form-I % Given H(z) b1 = [-14.a4).0]. A = [A.75 x(n) y(n) −1 z 56. [b4.7500 56.-1.875 −1 z 7.0000 -1.0500 1.B.23 −1 1.2366 -0.672 −1 −2.A) b = 9.237 −1 z z −1 −1 z z z −1 0.2787 -2.71 z −1 −1.4303 0.05 −2.4303 z −1 −0.9z −1 24. [b4.0500 1. b3 = [1.-12.82.3959 -11.23 −1 −2.0].67 −1 0.a3]).a4] = cas2dir(1.B.237 z −11.7500 56.0.0000 -1. b2 = [24.2325 7.a1].6666 -2.-7/8.B. [b.A) b = 9.6719 -39.875 z 56.b3].1].3/32].038 z −2.4303 z −1 −0.05 z −39.a4).279 z 7.5.[b2.4 −1 −1.9].4303 0.A] = dir2par(b4. B = [B.2366 -0.-1.71 y(n) .1/2].0380 a = 9.8750 2.0.7101 0 1. [C.75.26.81]. A = [A.75 x(n) −1 1.b1]. a1 = [1.2. a3 = [1.2787 -2.a] = par2dir(C.672 −1 2.2006 Solutions Manual for DSP using Matlab (2nd Edition) 283 2.[a2. a2 = [1. Normal direct form II: Matlab script: %% (b) Normal Direct form-II % Given H(z) b1 = [-14. 369 −1 −0.75.-12.0000 0.b3].0663 4. b3 = [1.A] = dir2cas(b. A = [A.2.0000 -0.a4] = cas2dir(1.26. a2 = [1.3691 -0.1/2].a1].a3]).-1. a1 = [1.7500 B = 1.0000 1.3/32].2731 6.a) b0 = 9.0.8750 0. [b0. Cascade form containing transposed second-order direct form II sections: Matlab script: %% (c) Transposed Cascade form % Given H(z) b1 = [-14.0937 . b2 = [24.0].0000 1.8748 0.5 −0.2731 z−1 0 6.81 y(n) z−1 1 −0. [b4.B.81].Solutions Manual for DSP using Matlab (2nd Edition) 284 2006 3.A] = dir2par(b4.5.9].0.0000 0.1]. B = [B.0000 1. a3 = [1.-7/8.[a2.b1].8100 0.75 x(n) 1 1 z−1 0.a] = par2dir(C.8748 0. [b.0663 1 z 4.792 −0.B. [C.a4).5000 0.0000 1.82.[b2.875 −1 z 0.7918 0 1.A).0000 -1.B.0937 A = 9. a1].A] = dir2par(b4.2767 82.A).-12.26.5000 1. A = [A.5 −14.28 0 −0.1234 -40. a1 = [1. [b4.2. a3 = [1.8750 0.875 −0.0000 0.12 x(n) y(n) −1 z −40. [C.82.-1.81 82.6234 57. Parallel form containing transposed second-order direct form II sections: Matlab script: %% (d) Transposed Parallel form % Given H(z) b1 = [-14.9733 -14.a3]).3/32].9000 A = 1.9].1].75.0937 285 . a2 = [1.5.2006 Solutions Manual for DSP using Matlab (2nd Edition) 4.0.a) C = 0 B = -58.81].75 z−1 −12.a4] = cas2dir(1.0937 −58.97 1 −0. B = [B.0.7500 -12. [C.B. [b.62 z−1 57.0000 -1.[b2.B.a4).0000 0.a] = par2dir(C.B.A] = dir2par(b.0000 -0.0].b1].1/2].b3].0000 0.[a2. b3 = [1.8100 1.-7/8.9 0. b2 = [24. 8710 -49.6124 0.[b2.B.5539 C = 43.1/2].0.2.71 −1 −1 −1 z z z −16. b3 = [1.0.1147 x(n) -0.-7/8.87 0 −1 z 43.b1].11 −49.B.a) K = -0.a3]).6124 −0.71 −61. Lattice-ladder form: Matlab script: %% Lattice-Ladder form % Given H(z) b1 = [-14. b2 = [24. a3 = [1.-12.0].A] = dir2par(b4.5069 0.a4).1].82.5539 0.81].2642 -61. A = [A.a] = par2dir(C.6124 0.1171 55.a4] = cas2dir(1.5.A).3596 0.6719 0. a2 = [1.5069 −0.3/32]. [b. [b4. a1 = [1.9].038 0.3596 −0.26 −1 z 55.-1.C] = dir2ladr(b.038 −0.6719 −1 z 0 −2.5069 -0.75.26.7101 −0.[a2.12 y(n) .Solutions Manual for DSP using Matlab (2nd Edition) 286 2006 5.5539 −0.0380 -16.3596 0. B = [B.a1].b3].6719 0.7111 -2. [K. [C. 0.C) b = 0.2000 0.1].1/2].0000 -0. [b. Direct form I: Given Lattice-Ladder K = [-0.6 z−1 z−1 −0.2006 Solutions Manual for DSP using Matlab (2nd Edition) P6.2000 -0. 1.2/3.a] = ladr2dir(K.5 x(n) y(n) z−1 z−1 0.0.5 1 287 .0000 a = 1.5000 0.2 z−1 −0.9 The causal linear time-invariant system describes the lattice/ladder structure.6000 0.2000 0.1].C) b = 0.a] = ladr2dir(K. C = [0.6000 1.6000 0.0000 -0.5000 0.0. C = [0.2000 -0.5000 0.2/3.0. [b.6000 1.2 z−1 z−1 1 −0.5 x(n) y(n) z−1 0.1/2].56.0000 a = 1.5000 0.56.5 2.6 z−1 −0. Direct form II:Given Lattice-Ladder K = [-0.6 −0.6 0.2 0.2 −0. 1731 0.B.5731 −1 −1 z −0.0000 -1.A] = dir2cas(b.0.3448 1.0000 0.1]. [b.345 z−1 −0.745 z 0 0 y(n) .0.5000 B = 1.a] = ladr2dir(K. C = [0.8724 1. [b0.1/2].146 1.0000 1.C).7448 0 A = 1.56.173 −1.8724 1.0000 -1.5 1 x(n) 1 z−1 1. Cascade form containing second-order direct form II sections: Given Lattice-Ladder K = [-0. b0 = 0.1463 1.a).5731 0 0.2/3.Solutions Manual for DSP using Matlab (2nd Edition) 288 2006 3. 0.1731 0.2006 Solutions Manual for DSP using Matlab (2nd Edition) 4.1201 −1 z −0.1]. C = [0. Parallel form containing second-order direct form II sections: Given Lattice-Ladder K = [-0.8724 −1.1/2].C). [b.B.5731 0 −1 z 0 289 .8724 1.a) C = 2 B = -0.225 z−1 −0.1201 -1.2748 0.A] = dir2par(b. [C.2748 z−1 1.2252 0 A = 1.2/3.173 0.a] = ladr2dir(K.56.0.5731 0 x(n) 2 y(n) −0.0000 0.0000 -1. .7751 1.01z −1 − 0.0000 0.0000 2.31].59 -1 1.7751 z-1 -1 2.1.4961 1.5732 0.0500 B = 1.0000 1.2.5732 0.-0.0.13.0000 0 A = 1.0.35.05 − 0.2611 0.8062 Block diagram: 0.0000 -1.0000 -1. The required form is the cascade form.0000 1.77.0821 0.13z −4 + 0.-0.0000 -1.88z −3 + 1.05.-0.5900 1.59z −2 − 0.A] = dir2cas(b.77z −1 + 1.35z −5 + 0.10 Given linear time-invariant system with system function: H (z) = 0.05z −6 1 − 0. Matlab script: b = [0.01.13z −2 + 0. [b0.1.2611 z -0.-0.01.59.2z −4 − 0.Solutions Manual for DSP using Matlab (2nd Edition) 290 2006 P6.4961 z-1 z 1 -0.3900 1.01z −5 − 0.B.-0.39 z -0.a) b0 = 0.8062 -1.31z −6 1. This solution is not unique since numerator and denominator biquads can be grouped differently.082 -1 z-1 -1 z 0 -1 1 2.88.13. a = [1.05 1 1 1 x(n) y(n) z-1 -0.-0.05].0.0000 -0. 3086 Block diagram: -0.9717 B = -0. a = [1.1.0.7519 0.0465 z -1 -0.11 Given linear time-invariant system with system function: H (z) = 0.0.3652 z 0.A] = dir2par(b.B.3086 This solution is unique.478z −2 − 0.051 + 0.4929 -0.34.088z −1 + 0.-0.4929 -1 0.0465 -0.6876 z -0.1983 0.a) C = -0.029.046].06.1983 x(n) -0.789z −3 + 0.8471 0. [C.8471 -0.3881 A = 1.-0.7519 1.088.2006 Solutions Manual for DSP using Matlab (2nd Edition) P6.06z −2 − 0.069.-0.789.069z −4 − 0.9717 z -1 -0. -1 -1 y(n) 291 .-0.0000 -0.388 z 0.0000 1.029z −3 − 0.0.232z −4 The given flow graph is a parallel structure.046z −5 1 − 1.3654 1.051.232]. Matlab script: b = [0.-1.478.6876 -0.34z −1 + 1. 2z −4 − 0. Matlab script: % Given Direct form b = [0.0000 0.0295 0.2939 1 0.77.1613 B = -0.0620 a1 = 1.01z −1 − 0. % Convert to a parallel form [C.59.-0.2439 0.0000 -0. a = [1.31].0262 z z -0.0.1.1168 -0.8062 % Convert the first two biquads into direct form [b1.0000 0.2056 A1 = -0.88z −3 + 1.0821 0.13z −4 + 0.3121 1.2654 -0.5732 1.13.2939 z z 0.1592 -0.1148 -0.01.88.:).1592 -0. b1 = real(b1).31z −6 1.a1] = par2dir(C.5732 0.13z −2 + 0.01.4961 -0.05.1.0821 0.4961 1.a) C = -0.4961 1.-0. a1 = real(a1) b1 = 0.2611 0.7206 -0.2878 0.0964 A = 1.0000 -1.1383 B1 = 1.3845 % Convert the resulting direct into cascade form [b0.05z −6 1 − 0.B1.2611 0.05].5732 0.:)).8062 z-1 2.2. The given signal flow graph is a parallel connection containing one second-order cascade branch.0964 -1 -1 -1 -1 y(n) -1 Block diagram: -0.-0.-0.1215 0.0820 0.0.-0.77z −1 + 1.A1] = dir2cas(b1.59z −2 − 0.0. .292 Solutions Manual for DSP using Matlab (2nd Edition) 2006 P6. The solution is not unique since any two out of three parallel biquads can be used to construct a cascade branch.7751 1.2439 1.2939 0.13.0000 1.A] = dir2par(b.0000 -0.05 − 0.35.1879 -0.7751 1.0000 0.-0.0262 1.01z −5 − 0.A(1:2.0000 -0.B(1:2.1383 1.2056 -0.35z −5 + 0.7751 z 1.0.a1) x(n) 1 b0 = 0.2611 -0.12 The linear time-invariant system function: H (z) = 0.B. 82 0.[1.a] = par2dir(C.2.4400 0.9.0000 0.5.[1.a1).3 z−1 0.1160 0.-0.72 z z−1 z−1 z−1 z−1 −1 −0. b1 = removetrailzeros(b1).5000 9.4]).1.a2). [C2.5.3000 22.a1] = cas2dir(1.1500 18.53 −1.8200 Block diagram: x(n) 3.02 −1 −0.0448 . % Overall direct [b. a2 = removetrailzeros(a2).5.5300 1. b = real(b).A2]).5.45 z−1 17.7300 11. 1.4.B1.-1. [C1. B = [B1.7200 -0.116 −0.3.1.[3.B2. A = [A1.378 −1 z 3.A).73 z−1 11.0].3000 0.6700 a = Columns 1 through 10 1.0.a2] = cas2dir(b0.A2].1].4.A2] = dir2cas([1.5 −1 z 9.B2].44 −0.B2.[1.4500 17.0.A2] = dir2par(b2. a = real(a) b = Columns 1 through 9 3.67 z−1 1.B2].2.0.0.5.9 −1.1152 z y(n) 1. Direct form (normal) structure: Matlab script: %% (a) Normal Direct form-I % Given Structure % Upper parallel branch [b1.1.9000 1.3780 0.[0.0448 z z−1 z−1 −1 0. % Lower parallel branch [b0. [b2.A1] = dir2par(b1.1.8 −0.3 z−1 22.B.8000 0.-0. % Overall parallel C = C1+C2.0.2006 Solutions Manual for DSP using Matlab (2nd Edition) 293 P6.2. b2 = removetrailzeros(b2).0.15 z−1 18.0200 3.8]).13 The filter structure contains a parallel connection of cascade sections. 0448 0.15 18.9.5. b = real(b).116 z−1 −0.[1.02 3.a] = par2dir(C.8 z−1 −0. % Overall parallel C = C1+C2.82 z−1 0.1].0200 3.6700 a = Columns 1 through 10 1.0.72 z −0.2.1500 18.B2]. a = real(a) b = Columns 1 through 9 3.5300 1.0000 0.B1.a2] = cas2dir(b0. b1 = removetrailzeros(b1).A2] = dir2par(b2.4500 17.B2.2.A2] = dir2cas([1.a2).0.4400 0.0.7300 11. b2 = removetrailzeros(b2).0.44 −1 11.3 22. [C1. [b2.3000 0.4]).1.3780 0. [C2.9 −1 17. A = [A1.-1.3 0.B2.1152 y(n) 1.4. % Overall direct [b.5.2.B2].A2].[0.294 Solutions Manual for DSP using Matlab (2nd Edition) 2006 2.73 z −1.a1). B = [B1.5.5000 9.5 −1 9.1.5.1160 0.8200 Block diagram: x(n) 3.0.5.1.A).9000 1.-0. .A2]).8000 0.[1.[1. Direct form (transposed) structure: Matlab script: %% (a) Transposed Direct form-II % Given Structure % Upper parallel branch [b1.67 1.53 z−1 −1.-0.1. a2 = removetrailzeros(a2).8]).0448 -0.3.378 z−1 −0.7200 -0.45 z −0.0.[3.B.A1] = dir2par(b1.3000 22. % Lower parallel branch [b0.4.a1] = cas2dir(1.0]. % Overall parallel C = C1+C2.2.a2] = cas2dir(b0.4387 0 z 0 z−1 0 y(n) .9118 1.[0.5.0. a2 = removetrailzeros(a2).5. [C2.B2].-0.4 −0.3323 z−1 0.4000 1.-0.0.[1. [b0.2423 z−1 −0.a1] = cas2dir(1.A2] = dir2par(b2. a = real(a).0000 0.a1).582 −0.749 z−1 0.1.B2].0000 1.8000 1.9118 1.2.B1.4. Cascade form structure containing second-order sections: Matlab script: %% (c) Normal Cascade form % Given Structure % Upper parallel branch [b1.0.5819 1.7486 1.1852 1 −0.0000 0.Bc.0000 1. A = [A1.0000 0 Ac = 1.B.0000 1.2.B2.7486 0.9377 z −0.0000 0.0000 0.1.A2]).0.A2].-1. b = real(b).Ac] = dir2cas(b. b2 = removetrailzeros(b2).a] = par2dir(C.0000 0.0000 -0.2423 1.9 1 1 1 1 1 −1 −1 −1 −1 −1 z 1. B = [B1.0.4000 0.0. [b2.4.1852 1. % Lower parallel branch [b0.1.A1] = dir2par(b1.9377 1.8]).1.[1.0000 -1.9387 0.7486 0.3323 0.0000 -0.1].5000 Bc = 1.0414 0.A2] = dir2cas([1.5.B2. % Overall direct [b.5.4]). [C1.3.2006 Solutions Manual for DSP using Matlab (2nd Edition) 295 3.5 −1 −0.041 z−1 0.9000 1.a2).9.0].0000 0.8 z 1.4387 0.4 z −0.A).9387 0.a) b0 = 3.0000 Block diagram: x(n) 3.5.[1.[3. % Overall parallel C = C1+C2.4 z−1 −3.a2] = cas2dir(b0.9387 0.296 Solutions Manual for DSP using Matlab (2nd Edition) 2006 4.9.0000 0.0.[1.4 −0.[3.0000 1.A2].-1.0000 0.2.1923 0 −0.9000 1.1.3.15 −0.1.8]).2.9387 −0.9118 1. [C2. b2 = removetrailzeros(b2).B2].0236 -3.024 z−1 −3.A1] = dir2par(b1.009 z−1 2. [C1. % Lower parallel branch [b0.0000 0.381 z−1 4.-0.0000 -0.A2] = dir2cas([1.5.0000 0.135 z−1 −0. a2 = removetrailzeros(a2).4]).9 A = 1.A2]). [b2.937 −1 z −1.9118 z−1 5.192 0.4000 0.4.a1).5.B2].a2).4370 6.[1.342 −0.437 z−1 6.5.0.a1] = cas2dir(1.1].0].2.1502 5.4387 0 −0.B2.B1.1.0000 -1.0.1349 -0. C = Block diagram: [] B = x(n) 0.4.3813 4.4387 0 z−1 0 z−1 y(n) .5.-0.0.4000 1.1. B = [B1.8 0. A = [A1.8000 1 1.B2.3424 -3.[0.5. Parallel form structure containing second-order sections: %% (d) Normal Parallel form % Given Structure % Upper parallel branch [b1.9370 -1.[1.A2] = dir2par(b2.0.0088 −1 2.0. A2 = [1.2575 2.9z −2 1 + −0.8 −0.Ac] = dir2cas(b.0000 0.56 z 0.-1.5z −1 + 1 + 0. B1 = [0.Bc.8.-1.6292 8.0.8 z 0.7200 1.0000 0.A2).4.1.9. H (z) as a rational function: Matlab script: % Given Structure % H1(z) in parallel form: Leave as is C1 = 2.9.A2] = dir2par(b2.9 −0.a2).3z −1 0. a = real(a) b = 8.2272 1.5022 z−1 −0.0000 -0.8038 1. [C2.7 −0. % H2(z) in cascade form: Convert to parallel form b0 = 1.8000 0.1.7.2700 -0. Cascade form structure: [b0.a) b0 = 8.2 − 0.482 y(n) .8z −1 + 0.3.4 + 0.1.0000 0.2903 2.8268 0.0.72.7846 1.B.4425 0.7z −1 + 0.0922 0.0000 -0. % Combine two parallel forms C = C1+C2.227 −1. b = real(b).8038 z−1 1.9000 0. B2 = [2.5.9 1 1 1 1 −1 −1 −1 −1 z 0.6 −0.4820 Ac = 1.B2.0194 a = 1.9z −1 + 0.4.0000 -1. B = [B1.0.5z −1 + 0.0000 0. A = [A1.5000 0.5].14 In filter structure shown the systems H1 (z) and H2 (z) are in parallel where H1 (z) = 2 + and  H2 (z) = 0.B2.B2].1.9999 z−1 0.9680 12.A2]. A1 = [1.3000 -0.6204 -3.-0.a2] = cas2dir(b0.0000 0.6276 8.7566 1.0589 -0.8000 1.5600 x(n) 8.2006 Solutions Manual for DSP using Matlab (2nd Edition) 297 P6.6000 12.72z −2  3 + 4z −1 + 5z −2 1 − 1.6000 Bc = 1.a] = par2dir(C.7200 17.5].5193 -0.9999 0.56z −2  1.8].0590 -0. % (a) Rational function H(z) [b.5 −0.1342 0.A).7846 0.0.3. [b2.0.0000 1.-0.7566 1.72 z −0.5022 -0.7000 0.8z −2 2 + z −1 − z −2 1 + 1.2.9000 1.0.0.8268 z−1 0.56]. 7000 1.5000 5.3000 0.2 z−1 −0.0000 1.4008 B = 0.563 z−1 −0.6943 5.298 Solutions Manual for DSP using Matlab (2nd Edition) 3.5629 12.71 z−1 1.0000 -1.5600 −10. Parallel form structure: [C.1424 A = 1.9 0.7 5.7200 0.B.a) C = -10.9000 1.A] = dir2par(b.8 5.72 12.4 −1 z 0.4000 0.5 −5.7065 -5.0000 -0.8 0.2000 -0.142 z−1 −0.0000 0.4 y(n) 0.5000 x(n) 0.9000 0.3 z−1 −0.8000 1.5 −1 z −0.694 −1 z −1.9 −0.56 2006 .8000 0. [C4.9 in the second parallel section.5502 in the first parallel section and −0. ps = roots(a).6368.8778. a4 = poly(ps([6:10])). ps = sort(ps).1500 0 % Parallel Section-2 b4 = poly(zs([6:10])).0635 B3 = -0.0000 1. zs = sort(zs).1057221e-8.4000 -1.B4.8255 -0.4609 A3 = 1.0300 0.-0.-147456e-8].0.0000 0.8778z −4 − 0.0.1319 0 -0.-893025e-10].B3.0000 -0. a3 = poly(ps([1:5])). Due to a mistake in labeling.a3) C3 = 4. % Given Rational Function b = [1.0. Matlab Script: clc.3500 0 Hence from inspection.6368z −4 − 0.-1.0815 -0.0000 1. a = [1.2245 0 1. [C3.15 The digital filter structure shown is a cascade of two parallel sections and corresponds to a 10th -order IIR digital filter system function H (z) = 1 − 2.a4) C4 = 4.2.0.-0.0.0. The correct block diagram is: . the two incorrect values are −0.9000 0.5395456e-8.1.0.48928.A4] = dir2par(b4.0000 1.0.-2. two of the multiplier coefficients in this structure have incorrect values (rounded to 4 decimals).65z −2 + 0.7747 0.2076 -0.0973 -0. format short. % Poles/Zeros of the System function zs = roots(b).17281z −6 + 1057221 × 10−8 z −8 − 893025 × 10−10 z −10 1.0000 1.65.8000 0.0.48928z −6 + 5395456 × 10−8 z −8 − 147456 × 10−8 z −10 1 − 1. % Poles and zeros chosen from each half to create two parallel sections % Parallel Section-1 b3 = poly(zs([1:5])). To locate these two multipliers and determine their correct values we will investigate their pole-zero structure and combine the appropriate pairs.17281.2006 Solutions Manual for DSP using Matlab (2nd Edition) 299 P6.2000 -0.2z −2 + 1.A3] = dir2par(b3.6300 0.1000 0.0304 A4 = 1.0635 B4 = -2.0.0.5052 -2.6000 0. B = [poly(zs([1.16 y(n) .poly(ps([3.4900 1.poly(zs([3.1600 1. 1.8 -0. Matlab script: %% (b) Overall Cascade structure containing the least number of multipliers % Combine the poles and zeros with the same magnitude but +.poly(ps([2.0635 -0. or −1).0000 -0.0000 1..0000 -0.0000 -0.2 z −1 0.6400 1.0000 -0.63 x (n) -2.0000 0.0304 z −1 z −1 0.4 z −1 0.end-2])).0000 -0.end-1])).0815 z −1 0.0000 -1.0635 4.0000 0.poly(zs([5.end])).09 −0.4609 -0. An overall cascade structure containing second-order section and which contains the least number of multipliers: This can be obtained by combining pole or zero pairs with the same magnitude but differing signs.2245 z −1 1. poly(zs([4.0400 A = 1..25 −0.8100 1.8255 z −1 -0.1 2006 -0.1319 z −1 -0.end])). x(n) 1 1 1 z−1 0 0 z−1 0 z−1 0..2500 1.49 −0. b0 = 1.64 1 0 z−1 0 z−1 0.end-1])).0000 -0.0000 -0.81 −1 1 0 z−1 0 z−1 0..poly(zs([2.Solutions Manual for DSP using Matlab (2nd Edition) 300 4.0000 -0.9 2.0973 -1.0000 -0.6 -0.0000 0.7747 z -0..03 -0.5052 -0.2076 z −1 -0.15 −1 y( n ) -0..36 0 z−1 0.end-3]))] B = 1.0000 -0.35 -2.end-3])).0000 -0.0900 The following block diagram has only 7 multipliers (not counting multiplication by 0.0000 0.signs.3600 1.end-4]))] A = [poly(ps([1. poly(ps([4.end-2])).0000 -0.0000 -0. 5) Since the term in the bracket on the right in (6. It is linear in ω and is given by    M −1 jω =− ω. Linear-phase structures for the symmetric form when M = 5 and M = 6: M=5 z−1 M =6 z−1 z−1 x(n) z−1 x(n) z−1 z−1 1 z−1 2 z−1 3 1 y(n) z−1 2 3 y(n) .16 A linear-phase FIR filter is obtained by requiring certain symmetry conditions on its impulse responses.5). If M is an odd number then H (e ) = M−1 X = 2 X = 2 X jω M−3 h(n) e − j ωn 0 = 2 X M−3 0 0 h(n) e− j ωn + h  M −1 2  h(n) e− j ωn + h  M −1 2  M−3 0 h(n) e − j ωn e +h − jω   M−1 2 M −1 2   + M−1 X + 2 X M+1 2 e − jω  M−1 2  + M−1 X h(n) e− j ωn M+1 2 h(M − 1 − n) e− j ωn M−3 e − jω  M−1 2  h(n) e− j ω(M−1−n) 0  M−3  M−3   X       2 2 X M−1 M−1 M−1 M −1 − jω 2 − j ω n− 2 j ω n− 2   =e h(n) e +h + h(n) e 2 0 0   M−3  X      2 M−1 M −1  − jω 2 h M − 1 + 2h(n) cos n − =e 2 2 0 (6.2006 Solutions Manual for DSP using Matlab (2nd Edition) 301 P6. In the case of symmetrical impulse response. if M is an even number then the term h M−1 = 0 in (6. Hence the phase response is still linear and is given by (6. the resulting phase response is given by the first term.6). 2 we get the term (M/2 − 1) in (6. 0 ≤ n ≤ M − 1. we have h(n) = h(M − 1 − n). 1.5) and instead of the term (M − 3)/2. 2.5) is real-valued. −π < ω ≤ π (6.6) ∠H e 2  Similarly. 8) ∠H e j ω = ± − 2 2 Similarly. Hence 2 H (e ) = M−1 X = 2 X jω M−3 h(n) e − j ωn = 0 M−3 0 h(n) e− j ωn − 2 X 0 M−1 X M+1 2 h(n) e− j ωn + M−1 X h(n) e− j ωn M+1 2 h(M − 1 − n) e− j ωn = M−3 M−3 2 X 2 X 0 h(n) e− j ωn −  M−3  M−3       2 2 X X M−1 M−1 M−1 − jω 2 − j ω n− 2 j ω n− 2   =e h(n) e − h(n) e 0 =e − jω  M−1 2   X 2h(n) sin 0 M−3 =e 0 0 M−3 2 − j   i h j ± π2 − M−1 ω 2 h(n) e− j ω(M−1−n) 2 X 2h(n) sin 0     M −1  n− 2 M −1 n− 2  (6.7) Again the term in the bracket on the right in (6.7) is real-valued and hence the resulting phase response is given by the first term.8). we have h(n) = −h(M − 1 − n). If M is an odd number then h M−1 = 0. Hence the phase response is still linear and is given by (6. we get the term (M/2 − 1) in (6. Linear-phase structures for the antisymmetric form when M = 5 and M = 6: M=5 M =6 z−1 z−1 x(n) z−1 x(n) z−2 −1 1 z−1 −1 z−1 −1 2 1 y(n) −1 z−1 2 −1 z−1 3 y(n) . 4.7). 0 ≤ n ≤ M − 1. −π < ω ≤ π (6. if M is an even number then instead of the term (M − 3)/2. It is a linear equation in ω and is given by    π M −1 ω. In the case of antisymmetrical impulse response.Solutions Manual for DSP using Matlab (2nd Edition) 302 2006 3. 0000 0.9|k−3| x(n − k) 1. Direct form: Matlab script: % % k b (a) Direct form Given FIR filter coefficients = [0:6].2006 Solutions Manual for DSP using Matlab (2nd Edition) 303 P6.4066 0. b = exp(-0.9*abs(k-3)) = 0.0000 0.9*abs(k-3)) = 0. Linear-phase form: Matlab script: % % k b (b) Linear-phase form Given FIR filter coefficients = [0:6].0672 0.4066 0.4066 z−1 z−1 z−1 0.1653 0.0672 0.1653 0.1653 x(n) 1 0.0672 The block diagram is: z−1 z−1 z−1 0.0672 .0672 y(n) 2.0672 0.0672 1 y(n) 0.1653 The block diagram is: z−1 z−1 z−1 z−1 z−1 z−1 0.1653 0.4066 1.17 An FIR filter is described by the difference equation y(n) = 6 X k=0 e−0.1653 0.4066 x(n) 0. b = exp(-0.4066 1.1653 0.4066 0. A] = dir2cas(b.a) b0 = 0.0000 -1.6235 z−1 −1 0.2015 2.0000 -0.625 −0.2470 1.0000 0 x(n) 1/7 2.6235 -0.6246 1.9010 0.445 −0.1817 5.2225 z−1 −1 .6235 z−1 −0. a = 1.802 The block diagram is: 0.278 y(n) −1 z −z−7 2.0000 0.5030 1.6235 -0.901 z−1 −1 1. b = exp(-0.901 z−1 1.0000 1.0366 −0.A] = dir2fs(b) C = 2.247 0.8872 −0.2225 z−1 −1.2225 A = 1.0000 2.9*abs(k-3)). b = exp(-0.0366 0.0000 The block diagram is: 0.0000 1.0000 1.2781 B = -0.0672 B = 1.9*abs(k-3)).2225 0.1817 1.2015 5.6978 1.B. Frequency sampling form: Matlab script: % (d) Frequency-sampling form % Given FIR filter coefficients k = [0:6]. Cascade form: Matlab script: % (c) Cascade Form % Given FIR filter coefficients k = [0:6].304 Solutions Manual for DSP using Matlab (2nd Edition) 2006 3.21 0. [C.0672 x(n) 1 1 1 −0.0000 -1.9010 0. [b0.8019 1.503 1 y(n) 4.8872 2.2100 0.0000 -0.B.0000 1.698 0.4450 1. 5766 0.0.8648 0.8648 −1.6721 1.0000 1.5739 -1.4501 -1.5650 1.a) b0 = 2 B = 1.0000 -1.0000 0.5.4].4364 1.565 1.9002 -6.3.-7.-7.18 A linear time-invariant system is given by the system function H (z) = 2 + 3z −1 + 5z −2 − 3z −3 + 4z −5 + 8z −7 − 7z −8 + 4z −9 1.0.-3.5.8.2006 Solutions Manual for DSP using Matlab (2nd Edition) 305 P6.4653 .2706 0 The block diagram is: 2 x(n) 1 1 1 1 1 1. Cascade form: Matlab script: % (b) Cascade form % Given FIR filter coefficients b = [2.8759 -0.0170 1.577 1.4.0000 -0.8.9146 1. a = 1.4. The block diagram is: z−1 x(n) 2 z−1 3 z−1 5 z−1 −3 z−1 z−1 0 4 z−1 0 z−1 8 z−1 −7 4 y(n) 2.5.3.1667 2.9146 0 y(n) 3.4].-7.-3.4.0.0.8. [K] = dir2latc(b) K = 2.7519 2.0000 1. Lattice form: Matlab script: % (c) Lattice form % Given FIR filter coefficients b = [2.1062 1.0000 1.B. Direct form: Matlab script: % (a) Direct form % Given FIR filter coefficients b = [2.0000 -1.271 3.A] = dir2cas(b.3. a = 1.-3.106 0. a = 1.6721 −0.0.4].0.9987 3.4364 0.999 0. [b0. 0.7369 z−1 0.6479 0.698 z−1 The block diagram is: −0.618 −0.9719 −1 z 1.0000 1.4152 0.9719 -0.298 z−1 0.017 1.2979 44.7369 0. Frequency sampling form: Matlab script: % (d) Frequency-sampling form % Given FIR filter coefficients b = [2.63 z−1 0.-3.0000 B = 0.9002 −6.0000 1.B.752 2.465 −1.4].9952 16. [C.0000 1.4653 0.618 −1 4.752 2.6180 1.0562 z−1 −1.017 1.0000 0.0000 -1.876 −0.5.0000 -0.618 −0. a = 1.9002 −6.0000 -16.5414 A = 1.6180 1.0000 0 1.45 −1.574 1.4653 −1 45 z−1 0.167 2 z−1 z−1 z−1 z−1 z−1 z−1 z−1 y(n) z−1 4.0000 0 −16 −z−1 x(n) 1/10 16 y(n) z−1 −z−10 3.876 −0.574 1.45 −1.5414 −1 z−1 .618 −0.4.4152 0.6980 -0.A] = dir2fs(b) C = 3.-7.6302 4.6180 1.6180 1.0000 1.465 −1.Solutions Manual for DSP using Matlab (2nd Edition) 306 2006 The block diagram is: x(n) 2 z−1 −1.8.0000 1.167 2 −1.0000 -1.0562 -0.087 0.0000 1.3.0.6479 −1 27.0867 27. 9) −k and the W M factor is also conjugate symmetric −k k WM = W MM−k = W M Then H (z) =  1 − z −M M can be put in the form 1 − z −M H (z) = M where L = M−1 2 for M odd. is conjugate symmetric the DFT  H˜ (0).2006 Solutions Manual for DSP using Matlab (2nd Edition) 307 P6. the DFT. . H˜ (k). . . M − 1 (6.11) −k −1 1 − WM z ( L ) . k = 1.10) H˜ (k) (6. k=0 H˜ (k) = ˜ ∗ H (M − k) = H˜ ∗ (−k).19 For real-valued FIR filters. L = M 2  M−1 X k=0 ∗ (6. . X . . ˜ (0) ˜ (M/2) H H . 2 . H˜ (k). The sum in (6.13) Proof. and h h i cos ∠ H˜ (k) − z −1 cos ∠ H˜ (k) −  Hk (z) = 1 − 2z −1 cos 2πk + z −2 M 2πk M i (6.11) can be expressed as (assuming M even)     M/2−1 M−1 X X H˜ (0) H˜ (k) H˜ (M/2) H˜ (k) 1 − z −M   H (z) = + + + −k −1 −k −1 M 1 − z −1 1 + z −1 1 − WM z 1 − WM z k=1 k=M/2+1    M/2−1  M−1 X H˜ (k) H˜ ∗ (M − k) H˜ (0) H˜ (M/2)  1 − z −M  X + + + =  −k −1 k ∗ −1 M 1 − z −1 1 + z −1 1 − WM z 1 − WM z k=1 k=M/2+1 #   " M/2−1 M/2−1 X X 1 − z −M H˜ (k) H˜ ∗ (k) H˜ (0) H˜ (M/2) = + + +  −k −1 −1 −k ∗ −1 M 1 − z 1 + z −1 1 − W z 1 − W z M M k=1 k=1 #    " M/2−1 −k ∗ −1 −k −1 X H˜ (k) − H˜ (k) W M z + H˜ ∗ (k) − H˜ ∗ (k)W M z 1 − z −M H˜ (0) H˜ (M/2) = + +  −k −1 −k ∗ −1 M 1 − z −1 1 + z −1 [1 − W M z ][1 − W M z ] k=1 Consider −k H˜ (k) − H˜ (k) W M ∗ −k −1 z −1 + H˜ ∗ (k) − H˜ ∗ (k)W M z  −k −1 −k ∗ −1 [1 − W M z ][1 − W M z ]  −k ∗ −1 −k −1 H˜ (k) + H˜ ∗ (k) − H˜ (k) W M z − H˜ ∗ (k)W M z =  ∗ −k −k 1 − 2z −1 [W M + W M ] + z −2 . Hk (z) + + −1 1 − z 1 + z −1 k=1 − 1 for M even.12) (6. . . . h i h ˜ −1 ˜ ˜ 2 H (k)cos ∠ H (k) − z 2 H (k). cos ∠ H˜ (k) −  = 1 − 2z −1 cos 2πk + z −2 M . . . . = 2 . H˜ (k). Hk (z) which completes the proof. 2πk M i . we obtain ( L ) 1 − (r z)−M X .19. Revised frequency-sampling structure: Replacing z → r z. we obtain and  H˜ (k) → H re j 2πk/M ≈ H˜ (k)  M−1 1 − (r z)−M X H˜ (k) H (z) ≅ H (r z) ≅ −k −1 M 1 − r WM z k=0   M−1 H˜ (k) 1 − (r z)−M X =  −k M 1 − WM r z −1 k=0  Following steps similar to those in P6. −k −k WM → r WM . H (z) is sampled at z k = re j 2πk/M . . . . M − 1 where r ≈ 1(but < 1). . k = 0.Solutions Manual for DSP using Matlab (2nd Edition) 308 2006 P6.11). in (6. 1.20 To avoid poles on the unit circle in the frequency sampling structure. . ˜ . . H˜ (0) H˜ (M/2) H (z) = 2 . H (k). rM = 1. phaH = angle(H)’.rM] = dir2fs(h.r) % Direct form to Frequency Sampling form conversion % ------------------------------------------------% [C. L 2. .B.rM] = dir2fs(h.A. . % M is even (6. Hk (z) + + M 1 − r z −1 1 + r z −1 k=1 where and M is even. h i h cos ∠ H˜ (k) − r z −1 cos ∠ H˜ (k) −  Hk (z) = 1 − 2r z −1 cos 2πk + r 2 z −2 M 2πk M i . . end H = fft(h. magH = abs(H). k = 1. .B. elseif nargin == 2 rM = r^M. % check even or odd M if (M == 2*floor(M/2)) L = M/2-1.r) % C = Row vector containing gains for parallel sections % B = Matrix containing numerator coefficients arranged in rows % A = Matrix containing denominator coefficients arranged in rows % rM = r^M factor needed in the feedforward loop % h = impulse response vector of an FIR filter % r = radius of the circle over which samples are taken (r<1) % M = length(h).M).14) . New Matlab function dir2fs: function [C.A. if nargin == 1 r = 1. 2006 Solutions Manual for DSP using Matlab (2nd Edition) 309 A1 = [1.2) = -r*cos(phaH(2:L+1)-(2*pi*k/M)). % initialize B and A arrays B = zeros(L.A.2.1) = cos(phaH(2:L+1)).0]. The frequency sampling structure for the impulse response given in Example 6.9801 .C1]’.8009 0.9801 −z 1.A1].1]/9.8090 0.1. % compute denominator coefficients A(1:L.809 −1 z 0.3. % M is odd A1 = [1.0849 1.3) = [r*r].6 using the above function: Matlab script: % 3. C1 = [real(H(1)).0].0000 -0.99) C = 0.-r.3090 -0.6019 0. A = [A.3).3059 1/5 A = x(n) 0.8009 −1 z −0.3059 −1 z −0.602 −0. % compute gain coefficients C = [2*magH(2:L+1).0000 -0.0. A(1:L.0000 B = Block diagram: -0. Example 6.2). A = ones(L.9801 −5 1. [C.6119 0.9900 0 rM = 0.r.-r.0849 0.5818 0. 3.rM] = dir2fs(h. B(1:L.5818 −0.6119 0.6 impulse response h = [1.2) = [-2*r*cos(2*pi*k/M)].95 1.309 z−1 −1.0000 1.9801 0.0.B. else L = (M-1)/2. C1 = [real(H(1))].9510 1 y(n) z−1 0.real(H(L+2))].2. end k = [1:L]’. % compute numerator coefficients B(1:L. 9 0. K 3 = 0. K 2 = 0.Solutions Manual for DSP using Matlab (2nd Edition) 310 2006 P6.0.9 Direct form Given Lattice Structure = [2. The block diagram of the lattice form is 2 x(n) −1 z 0.3.0.674 1.0000 2. % % K b K 1 = 0.622 2.6740 1.5.5 0.5 0.6220 2.76 2.0. The block diagram of the direct form is −1 −1 z −1 z z −1 z x(n) 2 2.6.8000 1.9].6 0.6. K 4 = 0.3.3 0.5.6 0.3 0.7600 2.8 y(n) 2.9 −1 z −1 z −1 z y(n) .21 Impulse response of an FIR filter with lattice parameters K 0 = 2. = latc2dir(K) b = 2.0. 8 z-1 -0.7992 0.6396 0.2. broots = round(real(roots(b))*10)/10.32768].32768z −5 1.12.8 (c) Cascade of one first-order section and two second-order sections: Matlab script: % Given FIR filter b = [1.599 −1. a = 1.-4.8000 0.0000 -0.a) b0 = 1 B = 1.2.6411 1.3277 z−1 2.8000 0.048 −0.8000 0.048.32768].8000 0.601 −0.12 2.8000 Block diagram: x(n) y(n) z-1 -0. [b0.6013 0.4.4 z−1 −4 z−1 1 y(n) z−1 (b) Cascade of five first-order sections: Matlab script: b = [1.A] = dir2cas(b.5995 0.0000 -1.048.-5.12z −3 + 2. Block diagram structures in the following form: (a) Normal direct form: z−1 z−1 z−1 z−1 z−1 x(n) 1 −4 6.4z −2 − 5.8 z-1 -0.0000 -1.4.048 −5.6.8 z-1 -0.048z −4 − 0.8 z-1 -0.12 z−1 6.6396 1. broots = broots’ broots = 0.6.-4.7992 0 Block diagram: 1 x(n) 1 1 1 −1.3277 y(n) Transposed direct form: x(n) −0.-5.22 Consider the following system function of an FIR filter H (z) = 1 − 4z −1 + 6.12.-0.2006 Solutions Manual for DSP using Matlab (2nd Edition) 311 P6.-0.4 −5.6411 0 y(n) .B. [C.2.2.-0.8957 B = -0. b2 = poly(broots(3:5)) b1 = 1.-5.6.12. Cascade-3 v.6400 b2 = 1.-4.64 -2. Samp # of Mults 5 5 5 5 9 0.4000 1.92 -1 z -0.9953 -0. Freq.9200 -0.048. broots = round(real(roots(b))*10)/10.312 Solutions Manual for DSP using Matlab (2nd Edition) 2006 (d) Cascade of one second-order section and one third-order section: Matlab script: % Given FIR filter b = [1. Cascade-1 iii.2934 x(n) 18.32768].6645 -0.0000 -1.4142 0.0000 0 1.B.4142 z−1 1 z−1 −1 18.6645 z−1 2.-5.5120 Block diagram: x(n) y(n) z -1 z -1 z -1 -1.0000 1.0000 0 Block diagram: 18.293 −0.4.0000 -2.0000 -1. Cascade-2 iv.0003 18.32768].12.6000 0. broots = broots’.9 −1 −z 1/6 0.0000 1.A] = dir2fs(b) C = 1.6 −0.0000 -1.6.512 (e) Frequency-sampling structure with real coefficients: Matlab script: % Given FIR filter b = [1.6 z -1 0.4.0003 y(n) z−1 −z−6 1. Direct ii.-0.0000 1.0000 1.048.0000 1. b1 = poly(broots(1:2)).-4.5996 0.9794 A = 1.9794 z−1 −1 . The computational complexity: −1 Structure i.9953 # of Adds 5 5 5 5 12 −0.4 1.0000 1. ◦ ◦ z 8 = 4 e− j 30 .z5. z3 = 1/r1*exp( j*theta1*pi/180).58 x(n) 1 1 y(n) 4. z5 = r2*exp( j*theta2*pi/180).2754 42. z7 = 1/r2*exp( j*theta2*pi/180).z3.5801 -8.z7.5801z −1 +42.58 42. Direct form structure: z−1 z−1 z−1 z−1 z−1 z−1 z−1 z−1 −8. 2.23 A causal digital filter is described by the following zeros: ◦ ◦ z 2 = 0. −8.25.5801 1.25 e j 30 . −113.7155 -113.2754.72 −113. 42. Phase response of the filter: % Pole-zero description r1 = 0. −113.7155z −2 −113. ◦ ◦ z 4 = 2 e− j 60 . 1.3 x(n) 1 162. z2 = r1*exp(-j*theta1*pi/180). z 3 = 2 e j 60 . theta2 = 60.72 −8.3 162. b = poly(z) b = 1.5801. −8. z4 = 1/r1*exp(-j*theta1*pi/180).5092 -113.5 y(n) .5. z 1 = 0.5801z −7 +z −8 Due to symmetry in the coefficients.7155 Hence H (z) = 1−8. z = [z1.2754 162.5801.58 42. z 7 = 4 e j 30 . 42.z6.25 e− j 30 .5092. z6 = r2*exp(-j*theta2*pi/180).2754z −3 +162. r2 = 0. z8 = 1/r2*exp(-j*theta2*pi/180).7155. Linear-phase form structure: z−1 z−1 z−1 z−1 z−1 z−1 z−1 z−1 −8. 162.z2.5092z −4 −113. z1 = r1*exp( j*theta1*pi/180). the phase response is ∠H (e j ω ) = −4ω.5 e− j 60 . 1} 3.2754. and poles: { pi }8i=1 = 0.z4.5 e j 60 .0000 -8. z 5 = 0.7155.7155z −6 −8.2754z −5 +42.3 42.z8].0000 42.72 −113. ◦ ◦ z 6 = 0. which is linear.5 −113. Impulse response of the filter: h(n) = {1. theta1 = 30.2006 Solutions Manual for DSP using Matlab (2nd Edition) 313 P6. 314 Solutions Manual for DSP using Matlab (2nd Edition) 2006 . d2 = (1+d1)*(10^(-As/20)).Chapter 7 FIR Filter Design P7.001.As] = delta2db(delta1. Matlab Verification: delta1 = 0.1737 As = 60.d2] = db2delta(Rp.0144 delta2 = 0.0032 315 .01.delta2] = db2delta(Rp.d2] = db2delta(Rp.As] = delta2db(delta1. (a) function [Rp.1 The absolute and relative (dB) specifications for a lowpass filter are related by (7.As) % d1 = Passband tolerance % d2 = Stopband tolerance % Rp = Passband ripple % As = Stopband attenuation K = 10^(Rp/20).delta2) % Conversion from Absolute delta specs to Relative dB specs % [Rp.delta2) % Rp = Passband ripple % As = Stopband attenuation % d1 = Passband tolerance % d2 = Stopband tolerance Rp = -20*log10((1-delta1)/(1+delta1)).delta2) Rp = 0.2). As = -20*log10(delta2/(1+delta1)).As) delta1 = 0. Matlab Verification: [delta1.As) % Conversion from Relative dB specs to Absolute delta specs. d1 = (K-1)/(K+1). % [d1.1) and (7. delta2 = 0.As] = delta2db(delta1. [Rp.0864 (b) function [d1. . n = 1. n=0 L= M −1 2  M−1 2    . 2. (M − 1)/2 and a(0) = h[(M − 1)/2].2 The Type-1 linear-phase FIR filter is characterized by a symmetric h(n) and M-odd. α= M−1 is an integer 2 Consider the frequency response H (e j ω ) given by jω H (e ) = M−1 X M−3 h(n)e − j ωn n=0 = 2 X h(n)e − j ωn n=0 +h     M−1 X M − 1 − j ω M−1 2 + h(n)e− j ωn e 2 M+1 n= 2 Using change of variables in the third sum: n → M −1−n ⇒ M +1 M −3 → . . Hence h(n) = h(M − 1 − n)).Solutions Manual for DSP using Matlab (2nd Edition) 316 2006 P7. M − 1 → 0. Then   M−1 M−1 2 2   X X Hr (ω) = a(0) + a(n) cos(ωn) = a(n) cos(ωn)   n=1 = L X n=0 a(n) cos(ωn). and h(M − 1 − n) → h(n) 2 2 we obtain M−3 H (e j ω ) = 2 X n=0 =e Hence h(n)e− j ωn + h − jω  M−1 2  M−3 2 X  M−3    2 X M − 1 − j ω M−1 2 e + h(n)e− j ω(M−1−n) 2 n=0  − j ωn+ j ω  M−1 2   M −1 2  M−3 2 X − j ω(M−1−n)+ j ω h(n)e +h + h(n)e  n=0 n=0   M−3  X          2 M−1 M−1 M−1 M −1 − jω 2 + j ω 2 −n − j ω 2 −n =e h + h(n) e +e   2 n=0   M−3  X       2 M−1 M −1 M −1 − jω 2 + −n =e h 2h(n) cos ω   2 2 n=0   M−3    2   M − 1 X M −1 Hr (ω) = h + −n 2h(n) cos ω   2 2 n=0 Define a(n) = 2h M−1 2  − n . . . 0 ≤ n ≤ M − 1. H e  jω = M−1 X n=0 M h (n) e− j ωn = 2 −1 X n=0 h (n) e− j ωn + M−1 X h (n) e− j ωn M 2 Change of variable in the second sum above: n → M −1−n ⇒ M M → − 1. M − 1 → 0. − jω  M−1 2  2 X n=1 2h      M 1 − n cos ω n − 2 2 M H e jω  =e − jω  M−1 2  M       2 X 1 1 b (n) cos ω n − ⇒ Hr (ω) = b (n) cos ω n − 2 2 n=1 n=1 2 X   (b) Now cos ω n − 12 can be recursively computed using the trigonometric identity: h ω h ωi ωi cos (2n − 1) = 2 cos [(n − 1)ω] cos − cos (2n − 3) . H e jω  = = = = Change of variable: P M2 −1 P M2 −1 h (n) e− j ωn + n=0 h (n)e− j ω(M−1−n) n=0      P M2 −1 − j ω M−1 − j ωn+ j ω M−1 − j ω(M−1−n)+ j ω M−1 2 2 2 e +e n=0 h(n) e        P M2 −1 − j ω M−1 + j ω M−1 − j ω M−1 2 2 −n 2 −n e +e n=0 h(n) e   M  M−1   P 2 −1 − j ω M−1 2 e −n ω n=0 2h(n) cos 2 M M M −n →n ⇒n =0→n = . 3. n = 2. n = −1→n =1 2 2 2 and cos Hence. and h (n) → h (n) 2 2 Hence. h(n) = h(M − 1 − n). .e.3 The Type-2 linear-phase FIR filter is characterized by symmetric h(n) and M-even.2006 Solutions Manual for DSP using Matlab (2nd Edition) 317 P7. 2 2 2 and hence can be written as a linear combination of higher harmonics in cos ω multiplied by cos   1ω ω cos = cos {cos 0ω} 2  2  3ω ω cos = cos {2 cos ω − 1} 2  2  5ω ω cos = cos {cos 0ω − cos ω + cos 2ω} 2 2 ω 2  . i. 0 ≤ n ≤ M − 1. Then. . . . i.e.       1 M −1 − n ω → cos ω n − 2 2 M H e Define b(n) = 2h M 2 jω  =e  − n ... α= M −1 is not an integer 2 (a) Consider. . M M    2 −1 1 ω X Hr (ω) = b (n) cos ω n − b˜ (n) cos (ωn) = cos 2 2 n=1 0 2 X where b˜ (n) are related to b (n) through the above trigonometric identities.318 Solutions Manual for DSP using Matlab (2nd Edition) 2006 etc. Hence. Note that the lowest harmonic frequency is zero and the highest harmonic frequency is (n − 1) ω in the cos ω n − 21 expansion. e.. M−1 H e Define c(n) = 2h M−1 2 H e  jω jω  = je  − n .4 The Type-3 linear-phase FIR filter is characterized by antisymmetric h(n) and M odd.2006 Solutions Manual for DSP using Matlab (2nd Edition) P7. α = is an integer 2 2 (a) Consider. h = 0. M−3 H e jω  = M−3 2 X h (n) e − j ωn n=0 = e −j = e −j  M−1 2  M−3 2 X n=0 M−3  M−1 2  2 X n=0 − 2 X h (n) e− j ω(M−1−n) n=0      − j ωn+ j ω M−1 − j ω(M−1−n)+ j ω M−1 2 2 h(n) e −e      + j ω M−1 − j ω M−1 2 −n 2 −n h(n) e −e M−3 = je −j  M−1 2  2 X 2h(n) sin n=0    M −1 −n ω 2 Change of variable: M −1 M −3 M −1 −n →n ⇒n =0→n = . n= →n=1 2 2 2 and sin    M −1 − n ω → sin (ωn) 2 Hence. i. M − 1 → 0. Then. 0 ≤ n ≤ M − 1.   M −1 M −1 h(n) = −h(M − 1 − n). and h (n) → −h (n) 2 2 n → M −1−n ⇒ Hence. = je − jω  M−1 2  − jω  M−1 2  2 X n=1 2h   M −1 − n sin (ωn) 2 M−1 M−1 2 X 2 X n=1 c (n) sin (ωn) ⇒ Hr (ω) = n=1 (b) Now sin(ωn) can be expressed as sin(ω) times a polynomial in cos(ω) as sin(ωn) = sin(ω)Un−1 [cos(ω)] c (n) sin (ωn) 319 . H e jω  = M−1 X M−3 h (n) e − j ωn n=0 = 2 X n=0 h (n) e− j ωn + M−1 X h (n) e− j ωn M+1 2 Change of variable in the second sum above: M +1 M −3 → . Hence.. Note that the lowest harmonic frequency is zero and the highest harmonic frequency is (n − 1) ω in the sin ωn expansion.320 Solutions Manual for DSP using Matlab (2nd Edition) 2006 where Un is a Chebyshev polynomial of the second kind. . Hr (ω) = M−1 M−3 2 X 2 X n=1 c (n) sin (ωn) = sin ω 0 c˜ (n) cos (ωn) where c˜ (n) are related to c (n) through the above trigonometric identities. i.e. sin(ω) = sin(ω) {cos(0ω)} sin(2ω) = sin(ω) {2 cos(ω)} sin(3ω) = sin(ω) {cos 0ω + 2 cos 2ω} etc. Thus sin(ωn) can be written as a linear combination of higher harmonics in cos(ω) multiplied by sin(ω). M − 1 → 0. i. i.5 The Type-4 linear-phase FIR filter is characterized by antisymmetric h(n) and M-even.  π M−1 2− 2  2 X n=1 2h      M 1 − n sin ω n − 2 2 M H e jω  =e − jω  π M−1 2 2  M       2 X 1 1 d (n) sin ω n − ⇒ Hr (ω) = d (n) sin ω n − 2 2 n=1 n=1 2 X   1 (b) Now sin ω n − can be written as a linear combination of higher harmonics in cos ω multiplied by 2  ω sin 2 ..e. n = −1→n =1 2 2 2       M −1 1 sin − n ω → sin ω n − 2 2 and Hence. α= M −1 is not an integer 2 (a) Consider. 0 ≤ n ≤ M − 1. M H e Define d(n) = 2h M 2  jω =e − jω  − n .. and h(M − 1 − n) → −h(n) n → M −1−n ⇒ 2 2 Hence.   1ω ω sin = sin {cos 0ω} 2  2  3ω ω sin = sin {1 + 2 cos ω} 2  2  5ω ω sin = sin {cos 0ω + 2 cos ω + 2 cos 2ω} 2 2 . M H e jω  = 2 −1 X M h (n) e − j ωn n=0 =e =e =e − jω  M−1 2  M 2 −1  − jω  M−1 2  M−1 2 n=0      − j ωn+ j ω M−1 − j ω(M−1−n)+ j ω M−1 2 2 h(n) e −e X      + j ω M−1 − j ω M−1 2 −n 2 −n h(n) e −e M 2 −1 n=0  h (n) e− j ω(M−1−n) X n=0 − jω − 2 −1 X M 2 −1 X 2 j h(n) sin n=0 Change of variable:    M −1 −n ω 2 M M M −n →n ⇒n =0→n = . h(n) = −h(M − 1 − n).2006 Solutions Manual for DSP using Matlab (2nd Edition) 321 P7. Then. H e  jω M−1 X = n=0 M 2 −1 X h (n) e− j ωn = n=0 h (n) e− j ωn + M−1 X h (n) e− j ωn M 2 Change of variable in the second sum above: M M → − 1.e. Hence. Note that the  lowest harmonic frequency is zero and the highest harmonic frequency is (n − 1) ω in the sin ω n − 12 expansion.322 Solutions Manual for DSP using Matlab (2nd Edition) 2006 etc. M M    2 −1 1 ω X Hr (ω) = d (n) sin ω n − d˜ (n) cos (ωn) = sin 2 2 n=1 0 2 X where d˜ (n) are related to d (n) through the above trigonometric identities. . L] = hr_type2(h). end end Matlab Verification: %% P7.6 Matlab Function: function [Hr.P.L] = ampl_res(h) % % Computes Amplitude response Hr(w) and its polynomial P of order L.P.6: Amplitude Response Function clc.P. [Hr. elseif fix(h(1:1:L)*10^10) == -fix(h(M:-1:M-L+1)*10^10) disp(’*** Type-4 Linear-Phase Filter ***’) [Hr.w. % % Hr = Amplitude Response % w = frequencies between [0 pi] over which Hr is computed % P = Polynomial coefficients % L = Order of P % h = Linear Phase filter impulse response % M = length(h). elseif fix(h(1:1:L)*10^10) == -fix(h(M:-1:M-L+1)*10^10) disp(’*** Type-3 Linear-Phase Filter ***’) h(L+1) = 0.P.w.w. end else if fix(h(1:1:L)*10^10) == fix(h(M:-1:M-L+1)*10^10) disp(’*** Type-2 Linear-Phase Filter ***’) [Hr.L] = hr_type1(h). L = floor(M/2). close all.L] = ampl_res(h). % given a linear-phase FIR filter impulse response h.2006 Solutions Manual for DSP using Matlab (2nd Edition) P7.P.w. % The type of filter is determined automatically by the subroutine. if fix(abs(h(1:1:L))*10^10) ~= fix(abs(h(M:-1:M-L+1))*10^10) error(’Not a linear-phase impulse response’) end if 2*L ~= M if fix(h(1:1:L)*10^10) == fix(h(M:-1:M-L+1)*10^10) disp(’*** Type-1 Linear-Phase Filter ***’) [Hr. %% 1. h_I(n) 323 .L] = hr_type3(h). % % function [Hr.w.w.P.L] = hr_type4(h). [Hr.*sin(pi*(n-4.0310 0. L *** Type-3 Linear-Phase Filter *** P = 0 -0.9).9).^abs(n-4.5)/11).1364 -1. h_IV = (0. [Hr.6561 L = 5 0.P.^abs(n-5).8100 -1.5).w. h_III = (0.5).2700 -0. h_I = (0.9).324 Solutions Manual for DSP using Matlab (2nd Edition) n = 0:10.9). P.0000 1. [Hr.P.5)/11).1615 0. h(n) n = 0:9.*cos(pi*(n-5)/12).P.4030 1. [Hr.L] = ampl_res(h_II).P.0064 -1.L] = ampl_res(h_I).9). L *** Type-1 Linear-Phase Filter *** P = 1.4659 -0.L] = ampl_res(h_III).0310 -1. h_II(n) n = 0:9. P.w.1944 L = 5 %% 5.5533 1.w.L] = ampl_res(h_IV).3057 %% 2. [Hr. h_III(n) n = 0:10. P.*cos(pi*(n-5)/12).w.1407 L = 5 %% 4. P.7094 -1.3507 L = 5 %% 3. L *** Type-2 Linear-Phase Filter *** P = 1.1636 -1.7387 1. h_II = (0.^abs(n-4.P.L] = ampl_res(h_IV).^abs(n-5).^n. h_IV(n) n = 0:9. L ??? Error using ==> ampl_res Not a linear-phase impulse response 2006 .w.7478 0. h_IV = (0.*sin(pi*(n-5)/12).*cos(pi*(n-4. L *** Type-4 Linear-Phase Filter *** P = -0. P.8781 1. 1 which is a finite-duration symmetric impulse response. r z 3 = re− j θ . 3. − r + r ↑ −1   . The filter H (z) has the following two zeros z 1 = r and z 2 = 1 r The system function can be written as     1 1 − z 2 z −1 = 1 − r z −1 1 − z −1 r  −1 −1 −2 = 1− r +r z +z H (z) = 1 − z 1 z −1  Hence the impulse response of the filter is  h(n) = 1.7 Properties of linear-phase FIR filters: 1. This implies that the filter is a linear-phase FIR filter. −2 cos θ r + r . r + r + 4 cos θ . −2 cos θ r + r ↑ which is a finite-duration symmetric impulse response. 2. . −2 cos θ.1 h (n) = 1. z2 = 1 jθ e .2006 Solutions Manual for DSP using Matlab (2nd Edition) 325 P7. This implies that the filter is a linear-phase FIR filter. This implies that the filter is a linear-phase FIR filter. The filter H (z) has the following two zeros z 1 = e j θ and z 2 = e− j θ The system function can be written as     H (z) = 1 − z 1 z −1 1 − z 2 z −1 = 1 − e j θ z −1 1 − e− j θ z −1  = 1 − (2 cos θ) z −1 + z −2 Hence the impulse response of the filter is  h(n) = 1. 1  ↑ which is a finite-duration symmetric impulse response. The filter H (z) has the following four zeros z 1 = re j θ . 1 z 4 = e− j θ r The system function can be written as     H (z) = 1 − z 1 z −1 1 − z 2 z −1 1 − z 3 z −1 1 − z 4 z −1       1 j θ −1 1 − j θ −1 j θ −1 − j θ −1 = 1 − re z 1− e z 1 − re z 1− e z r r    −1 2 −2 −1 −1 = 1 − (2r cos θ) z + r z 1 − 2r cos θ z + r −2 z −2    = 1 − 2 cos θ r + r −1 z −1 + r 2 + r −2 + 4 cos2 θ z −2 − 2 cos θ r + r −1 z −3 + z −4 Hence the impulse response of the filter is      −1 2 −2 2 −1 . 0.3]).[0.1. h_II(n) n = 0:9. h_IV = (0.’Name’.326 Solutions Manual for DSP using Matlab (2nd Edition) 2006 4. h(n) n = 0:9.’Name’. %% 1. ’color’. Hf_3 = figure(’Units’.0].3.3].0].7.1.’off’.0]. set(Hf_2.1.[1.’inches’.’P7.’Name’.3.’paperunits’.9).[0.1).[0. set(Hf_5. title(’{\ith}_{IV}({\itn})’) %% 5. h = (0..’NumberTitle’.’P7.0]. set(Hf_3.3’). zplane(h_II.0.^abs(n-5).’position’.*cos(pi*(n-5)/12)..3].3. h_I = (0.’inches’.0.’inches’.’position’.1’).[0.’paperunits’.’inches’.’paperposition’. h_IV(n) n = 0:9.*cos(pi*(n-5)/12).’P7. set(Hf_4.0.’inches’.’NumberTitle’.. zplane(h_IV.0.’paperposition’.0.7.3]).0.’NumberTitle’.’NumberTitle’. Hf_1 = figure(’Units’...’position’. h_III(n) n = 0:10.’P7.7. If H (z) has a zero at z 1 = 1 or a zero at z 1 = −1 then H (z) can be written as H (z) = (1 − z −1 ) or H (z) = (1 + z −1 ) with impulse responses     h(n) = 1. Clearly the first four plots satisfy the zero-placement requirements and hence the corresponding filters are linear-phase filters. close all..’inches’.3.1).^abs(n-4.0. Zero plots using Matlab : %% P7.1).’position’. Hf_4 = figure(’Units’.[0.*sin(pi*(n-5)/12).1).*cos(pi*(n-4. 1 or h(n) = 1.7. h_I(n) n = 0:10.3. ’color’.5)/11).[0.^abs(n-5).[0.1. zplane(h.5)/11).^abs(n-4.3].3]). ’color’. title(’{\ith}({\itn})’) The zero-plots are shown in Figure 7...[1.[0.’paperunits’. ’color’.0].3. ’color’.’off’.’position’.[1.’inches’. −1 ↑ ↑ both of which are finite-duration with symmetric and antisymmetric impulse responses..7. title(’{\ith}_{II}({\itn})’) %% 3. set(Hf_1. 5...9).5).3.’P7.’inches’.’inches’.[1.3.9).’paperposition’. title(’{\ith}_{III}({\itn})’) %% 4.’off’.1. zplane(h_III..3]. h_III = (0.[0.3.5). Hf_2 = figure(’Units’.’paperunits’. title(’{\ith}_{I}({\itn})’) %% 2. h_II = (0.’NumberTitle’.’off’..9). respectively.2’). .3]).7: Pole-Zero Plots of Linear-Phase Filters clc. zplane(h_I.4’).^n.’inches’.1).3]).9).[1.*sin(pi*(n-4.’paperunits’.0.’Name’.3.1.’paperposition’.[0..’off’.3].’Name’. Hf_5 = figure(’Units’.0.5’).’paperposition’. This implies that the filter is a linear-phase FIR filter.. 2006 Solutions Manual for DSP using Matlab (2nd Edition) 1 0.7 .4 −0.1: Plots of zeros in Problem 7.2 9 0 −0.5 0 Real Part Real Part hIII(n) hIV(n) 1 0.6 Imaginary Part 1 0.6 −0.5 9 0 −0.8 Imaginary Part Imaginary Part hI(n) 327 0 0.5 0.4 −0.6 0.5 1 −0.4 −0.2 10 0 −0.2 −0.6 −0.5 1 Real Part Figure 7.2 −0.8 0.2 −0.8 0.2 −0.5 −0.2 −0.4 −1 −1 0.4 0.8 −1 −1 −0.6 0.6 −1 Imaginary Part hII(n) 0.8 −1 −0.4 0.5 0 0.8 0.8 0.8 −0.4 0.6 0.5 0 Real Part Real Part h(n) 1 0.6 Imaginary Part 1 0.2 10 0 −0.5 0.6 −0.4 −1 1 −1 −0.4 0.2 −0.5 1 −1 −0.2 −0.8 0.4 0.8 0 1 0.6 −1 9 0 −0. The ideal linear-phase notch filter frequency response is given by   0. otherwise.328 Solutions Manual for DSP using Matlab (2nd Edition) 2006 P7. of the ideal notch filter. (b) Using h d (n). h d (n). (c) Repeat the above part using a length 51 Hamming window. |ω| = ω0 . (a) Determine the ideal impulse response. .8 A notch filter is an LTI system which is used to eliminate an arbitrary frequency ω = ω0 . Plot amplitude the response of resulting filter. jω Hd e = (α is a delay in samples) − j αω 1·e . Compare your results. design a linear-phase FIR notch filter using a length 51 rectangular window to eliminate the frequency ω0 = π/2 rad/sample. set(gca.As).4]). if (delta1 < delta2) delta2 = delta1.2*pi/tr_width).’off’. % lower stopband edge wp1 = 0.1). set(Hs_1. xlabel(’n’). ’paperunits’.’P7.delta2] = db2delta(Rp.2.’markersize’.[0.9 Design of a linear-phase bandpass filter using the Hann window design technique with specifications: lower stopband edge: 0. ylabel(’w_{han}(n)’).’position’.w_han.’filled’).[0.1. ylabel(’h_d(n)’) subplot(2.2006 Solutions Manual for DSP using Matlab (2nd Edition) P7.55π As = 40 dB R p = 0.3).2*pi.’paperposition’. title(’Ideal Impulse Response’).9’).8) axis([-1. Hs_1 = stem(n.0. % Actual Attn Asd = 44 % %% Filter Response Plots Hf_1 = figure(’Units’. title(’Hann Window’). % choose odd M M = 43 n = 0:M-1.35*pi.1].’XTick’.25.* w_han. %% Specifications: ws1 = 0.w] = freqz_m(h. % Actual passband ripple Rpd = 0.. Rpd = -min(db((wp1/delta_w)+1:(wp2/delta_w)+1)).As] = delta2db(delta1.25 dB clc.’fontsize’.’NumberTitle’.1030 Asd = floor(-max(db(1:(ws1/delta_w)+1))).’filled’).4]. axis([-1.[0.0].1.min(hd)-0.(ws2-wp2)).1. Hs_1= stem(n. h = hd .6. % stopband attenuation % % Select the min(delta1.3).’inches’.0. disp(’Delta1 is smaller than delta2’) [Rp. delta_w = pi/500.8) 329 .6. close all.1]). subplot(2. set(Hf_1.mag.2.[0.1]).-0.M-1]. w_han = (hann(M))’.. set(gca.’inches’.’color’..’fontsize’.max(hd)+0. set(Hs_1.delta2) end % tr_width = min((wp1-ws1).’fontsize’.’markersize’.75*pi.’Name’. % passband ripple As = 40.M).75π lower passband edge: 0.35π upper passband edge: 0.’XTick’.pha. % lower passband edge wp2 = 0. % upper stopband edge Rp = 0. M = ceil(6.55*pi.8). M = 2*floor(M/2)+1.1). [db.grd. wc2 = (ws2+wp2)/2. wc1 = (ws1+wp1)/2.[1.hd.M)-ideal_lp(wc1.[0.2).M-1]. xlabel(’n’).’YTick’.1.M.M.delta2) since delta1=delta2 in windodow design [delta1. hd = ideal_lp(wc2.2π upper stopband edge: 0. % upper passband edge ws2 = 0. set(gca. ’0.1]) set(gca.Solutions Manual for DSP using Matlab (2nd Edition) 330 2006 subplot(2.’filled’).’YTick’.4).2 0 0 42 0 n Actual Impulse Response 0 0.55’.35’.0.2.min(hd)-0.1).’ 1 ’].’linewidth’.0.’fontsize’.2 0.8) set(gca.[’ 0 ’.35 n Figure 7. Hs_1 = stem(n. xlabel(’\omega/\pi’).[’ 40’.1]).2.M.2 h(n) 42 n Magnitude Response in dB 0 40 −0.2: Filter design plots in Problem 7.’fontsize’.8) axis([-1.2 ’.35.75’.75.4 Decibels 0.2.1.0]).[-40. ylabel(’Decibels’) set(gca.’ 0 ’]). plot(w/pi.-As-30. set(gca.’XTick’.55 ω/π 0.2 0 −0.’XTick’.9 0. set(gca.’markersize’.h.5]).max(hd)+0.db. title(’Actual Impulse Response’).4 whan(n) hd(n) 0. title(’Magnitude Response in dB’).3).3).’YTickLabel’.0. axis([0. xlabel(’n’).0. Hann Window Ideal Impulse Response 1 0.[0.’0. ylabel(’h(n)’) subplot(2. set(Hs_1.[0.’XTickLabel’.’0.75 1 .55.2.M-1].1.’0.grid The filter response plots are shown in Figure 7.2 0 42 0 0. * w_ham.grd.1..1.’markersize’. set(Hs_1.max(hd)+0. delta_w = pi/500. wc2 = (ws2+wp2)/2.[0. axis([-1. w_ham = (hamming(M))’.1]).. hd = ideal_lp(pi.w_ham.’filled’). disp(’Delta1 is smaller than delta2’) [Rp.1).2.6. [db. % Actual passband ripple Rpd = 0.6*pi.delta2) since delta1=delta2 in windodow design [delta1. ’paperunits’.’markersize’.As] = delta2db(delta1.0.2 dB clc.3*pi. % passband ripple As = 50. % Actual Attn Asd = 50 Rpd = -min(db(1:floor(wp1/delta_w)+1)).2.M.. %% Specifications: wp1 = 0.’off’.’P7.mag.pha.0. % stopband attenuation % % Select the min(delta1.M)-ideal_lp(wc2. % upper stopband edge wp2 = 0.delta2) end % tr_width = abs(min((wp1-ws1).4π 0. M = 2*floor(M/2)+1.’inches’.2).4]). ylabel(’h_d(n)’) subplot(2. set(gca. Asd = floor(-max(db(ceil(ws1/delta_w)+1:floor(ws2/delta_w)+1))).M).[0.hd.3).7*pi.’NumberTitle’.1.8) axis([-1.6. xlabel(’n’).(ws2-wp2))). Hs_1 = stem(n. if (delta1 < delta2) delta2 = delta1.min(hd)-0.’paperposition’.2. . ylabel(’w_{ham}(n)’).0].M)+ideal_lp(wc1. set(Hf_1.3π 0. Hs_1= stem(n.2006 Solutions Manual for DSP using Matlab (2nd Edition) 331 P7.’color’. M = ceil(6.4*pi.’Name’. % lower stopband edge ws2 = 0.delta2] = db2delta(Rp.1]).0435 % %% Filter Response Plots Hf_1 = figure(’Units’.[0. subplot(2.w] = freqz_m(h. xlabel(’n’).6π 0.10’).M-1].’XTick’. title(’Hamming Window’). title(’Ideal Impulse Response’).’filled’). h = hd .[1. close all. % choose odd M M = 67 n = 0:M-1.3).’inches’. % upper passband edge Rp = 0. % lower passband edge ws1 = 0. set(Hs_1.4].-0.6*pi/tr_width). wc1 = (ws1+wp1)/2.As).1.M.1).7π As = 50 dB R p = 0.’fontsize’.’position’.10 Design of a bandstop filter using the Hamming window design technique with specifications: lower stopband edge: upper stopband edge: lower passband edge: upper passband edge: 0. [0.’XTickLabel’.’ 0 ’]).[’ 0 ’.’linewidth’.4).7.2 0 0 −0.6 0.3: Filter design plots in Problem 7. set(gca.10 0. set(Hs_1.M-1]. title(’Actual Impulse Response’).6 Decibels h(n) 0.0.db.4’.M-1].8) axis([-1.’YTick’.5]).7 ω/π 1 . xlabel(’n’).2 50 0 −0. title(’Magnitude Response in dB’).0.1].6’.’YTick’.’ 1 ’].’fontsize’.’0. set(gca.[0.3.3.grid The filter response plots are shown in Figure 7.1.M.0.1]).4 0. ylabel(’h(n)’) subplot(2.7’.min(hd)-0.3’.h.8 1 wham(n) 0. Hamming Window Ideal Impulse Response 0.8 0 0.’0. plot(w/pi.-As-30.1]) set(gca.’markersize’.’filled’).’0. ylabel(’Decibels’) set(gca.2 0 66 0 n Actual Impulse Response 66 n Magnitude Response in dB 0. axis([0.4 d h (n) 0.’fontsize’.Solutions Manual for DSP using Matlab (2nd Edition) 332 2006 set(gca.0.[-50. set(gca.2.’YTickLabel’.3).8) set(gca.’XTick’.[0.’XTick’. Hs_1 = stem(n.1).8).’0.1.6 0.[’ 50’.2 0 66 0 0.2.max(hd)+0.0]).3).4 n Figure 7.4.6.’fontsize’.[0.8) subplot(2.’fontsize’.’XTick’. xlabel(’\omega/\pi’).3 0. As).2.5 dB clc. % choose odd M M = 67 n = 0:M-1. wc2 = (ws2+wp2)/2. M = ceil(6. close all.w] = freqz_m(h. title(’Ideal Impulse Response’).’inches’. % Actual Attn Asd = 51 % %% Filter Response Plots Hf_1 = figure(’Units’. set(Hf_1.’off’. if (delta1 < delta2) delta2 = delta1.M)-ideal_lp(wc1.’Name’.min(hd)-0.3*pi.’paperposition’. [db. M = 2*floor(M/2)+1. % lower stopband edge wp1 = 0. % stopband attenuation % % Select the min(delta1.0.0488 Asd = floor(-max(db(1:(ws1/delta_w)+1))). Rpd = -min(db(ceil(wp1/delta_w)+1:floor(wp2/delta_w)+1)). axis([-1.4].[0.hd.6*pi. h = hd ..’position’.’color’.3). % upper passband edge ws2 = 0.M). disp(’Delta1 is smaller than delta2’) [Rp.’XTick’. xlabel(’n’). set(Hs_1. set(gca. . xlabel(’n’). delta_w = pi/500.5*pi.’inches’.1.’markersize’.6.6.’filled’). % Actual passband ripple Rpd = 0..As] = delta2db(delta1. ylabel(’h_d(n)’) subplot(2.4]).3π 0.1]).4π 0.5π As = 50 dB R p = 0.[0. ’paperunits’. w_ham = (hamming(M))’.pha.* w_ham.M.(ws2-wp2))).M.3).1).-0.6π 0. ylabel(’w_{ham}(n)’).mag.M-1].1]).1.w_ham.0.1.[0.grd.1)..delta2] = db2delta(Rp.11 Design of a bandpass filter using the Hamming window design technique with The specifications: lower stopband edge: upper stopband edge: lower passband edge: upper passband edge: 0.5.11’). % passband ripple As = 50.4*pi. Hs_1 = stem(n.1.2.0].’filled’).’markersize’. title(’Hamming Window’). subplot(2.’fontsize’.2006 Solutions Manual for DSP using Matlab (2nd Edition) 333 P7.8) axis([-1. hd = ideal_lp(wc2.delta2) end % tr_width = abs(min((wp1-ws1).delta2) since delta1=delta2 in windodow design [delta1. Hs_1= stem(n. % lower passband edge wp2 = 0.’P7. set(Hs_1. %% Specifications: ws1 = 0. % upper stopband edge Rp = 0.2).6*pi/tr_width).[1.max(hd)+0.’NumberTitle’. wc1 = (ws1+wp1)/2. M-1].2.’YTick’.3 0.3.5.Solutions Manual for DSP using Matlab (2nd Edition) 334 2006 set(gca. title(’Magnitude Response in dB’).3). ylabel(’h(n)’) subplot(2. ylabel(’Decibels’) set(gca. set(gca.’XTick’.[’ 50’. plot(w/pi.1 0 −0.1].[-50.’ 1 ’].5]).11 1 .8) set(gca.8) axis([-1.2 wham(n) d h (n) 0.h.’ 0 ’]).’fontsize’.1 50 −0.4.’fontsize’.8).0]).’0.4’.[0. xlabel(’\omega/\pi’).0.’YTick’.’XTickLabel’.’0.’XTick’.8) subplot(2. set(Hs_1. title(’Actual Impulse Response’).’fontsize’.5’.0. Hamming Window Ideal Impulse Response 0.3’.1 −0.1 0 −0. xlabel(’n’).db.’fontsize’.’0.1]).4 0.2 Decibels h(n) 0. set(gca.4).1]) set(gca.0.3).grid The filter response plots are shown in Figure 7.’XTick’.6.’linewidth’. axis([0.3 1 0.’YTickLabel’.-As-30.5 0.2 0 0 66 0 n Actual Impulse Response 66 n Magnitude Response in dB 0.M.[0.1.1).’filled’).[’ 0 ’.2.M-1].’markersize’.[0.’0.6 ω/π Figure 7. set(gca.1.4: Filter design plots in Problem 7. Hs_1 = stem(n.4.min(hd)-0.2 0 66 n 0 0.6’.3 0 0.0.[0.max(hd)+0. ’XTick’.’paperposition’. R p = 0. title(’Zoomed Magnitude Response in dB’). axis([0. [db. set(gca.’linewidth’.1]) set(gca.004.mag. plot(w(301:501)/pi. hd = ideal_lp(pi.’Name’.0.M).001 dB clc. M = ceil(11*pi/tr_width).4*pi.w] = freqz_m(h.3]. if (delta1 < delta2) delta2 = delta1.’XTickLabel’.’inches’.[1.005.[’0. M = 2*floor(M/2)+1.6*pi. % stopband attenuation % % Select the min(delta1. disp(’Delta1 is smaller than delta2’) Delta1 is smaller than delta2 [Rp. %% Specifications: ws = 0. close all.0039 Asd = floor(-max(db(1:(ws/delta_w)+1))).’color’.[0.delta2) Rp = 0. ylabel(’Decibels’) set(gca.4π.[0. w_blk = (blackman(M))’.2006 Solutions Manual for DSP using Matlab (2nd Edition) 335 P7.-0.0].1.delta2) since delta1=delta2 in windodow design [delta1.’YTickLabel’. ’paperunits’.7577 end % tr_width = abs(wp-ws).6. h = hd .db(301:501).004..’inches’.1).0]).delta2] = db2delta(Rp.6’. Rpd = -min(db(ceil(wp/delta_w)+1:floor(pi/delta_w)+1)). % passband ripple As = 50.1).6.’P7.1.As)..[-0.’fontsize’.[0.12 Design of a highpass filter using the Blackman window design with specifications: stopband edge: 0.3]).M)-ideal_lp(wc. % passband edge Rp = 0.8) set(gca.5.As] = delta2db(delta1. xlabel(’\omega/\pi’).’ 1 ’]..001]). % stopband edge wp = 0.’YTick’.6π.0.’position’. set(Hf_1.* w_blk. % Actual passband ripple Rpd = 0. As = 50 dB passband edge: 0.0040 As = 72.’off’. % Actual Attn Asd = 71 % %% Zoomed Filter Response Plot Hf_1 = figure(’Units’.grid .12’).’NumberTitle’.pha.5.grd.004’.0. % choose odd M M = 55 n = 0:M-1.[’-0. wc = (ws+wp)/2. delta_w = pi/500.’ 0 ’]). 004 0.5.6 1 ω/π Figure 7. Zoomed Magnitude Response in dB Decibels 0 −0.12 .Solutions Manual for DSP using Matlab (2nd Edition) 336 2006 The zoomed magnitude filter response plot is shown in Figure 7.5: Filter design plots in Problem 7. ’paperunits’.[0.2006 Solutions Manual for DSP using Matlab (2nd Edition) 337 P7.75*pi.4]).975 ≤ |H (e j ω )| ≤ 1.delta2) Rp = 0.005.M). xlabel(’n’). jω 0 ≤ |H (e )| ≤ 0. M = 2*floor(M/2)+1.13’).’NumberTitle’.7.1).005.[1.hd.1102*(As-8.’fontsize’. wc2 = (ws2+wp2)/2.25*pi.’Name’. title(’Ideal Impulse Response’)..3).M-1].w. beta = 0.M)+ideal_lp(wc1.[0.7.25π 0. delta_w = pi/500. % Ideal HP Filter h = hd .0].As] = delta2db(delta1. M = ceil((As-7.0.1.0. Hs_1= stem(n. subplot(’position’.grd.65*pi.4344 As = 46. ..* w_kai.025.08.’color’. hd = ideal_lp(pi.6.’position’. % Actual passband ripple Rpd = 0.975 ≤ |H (e j ω )| ≤ 1. % upper passband edge delta1 = 0. Asd = floor(-max(db(ceil(ws1/delta_w)+1:floor(ws2/delta_w)+1))). % passband ripple delta2 = 0.[0.025.0. % lower stopband edge ws2 = 0.285*tr_width)+1)+1.P.7).35π ≤ ω ≤ 0. 0.35*pi.0.35]). ylabel(’h_d(n)’).M)-ideal_lp(wc2.8) axis([-1.L] = Ampl_res(h). set(Hf_1.’filled’).’paperposition’.0492 [Hr.65π 0.’inches’.’off’. set(Hs_1.2351 % tr_width = abs(min((wp1-ws1). set(gca. % Kaiser Window wc1 = (ws1+wp1)/2.(ws2-wp2))).’inches’.025. % choose odd M M = 57 n = [0:1:M-1].13 Design of a linear-phase FIR digital filter Using the Kaiser window method that meets the following specifications: 0 ≤ ω ≤ 0.w] = freqz_m(h. % Window design [db. % %% Filter Response Plots Hf_1 = figure(’Units’. w_kai = (kaiser(M.95)/(2.1. % lower passband edge ws1 = 0.4].beta))’. % stopband ripple % % Convert to decibels [Rp.. % upper stopband edge wp2 = 0.M.25.0.min(hd)-0. 0.’markersize’.1]).max(hd)+0.’XTick’.’P7. %% Specifications: wp1 = 0.[0.pha.mag.75π ≤ ω ≤ π clc. close all. % Actual Attn Asd = 49 Rpd = -min(db(1:floor(wp1/delta_w)+1)). title(’Actual Impulse Response’).’linewidth’.3).0.’YTick’.1]).0. set(gca. axis([0.’XTickLabel’.35’.[’ 49’.’0.74.max(hd)+0.4 hd(n) Actual Impulse Response 0 0.75.[0.65 0.[0. xlabel(’n’).35 ω/π 0.[-Asd.’0.1]).1.1).0.0.[’ 0 ’.’ 1 ’]. subplot(’position’.’0.3). axis([-1.0. ylabel(’h(n)’).0.35 0.05.’ 0 ’]).2 h(n) wham(n) 0.M.65. plot(w/pi.’0.75’.[0.41.’filled’).6.[0.4 0. grid.0.[0.’filled’).25’.0]). xlabel(’\omega/\pi’). title(’Kaiser Window’).35]).6 0.’XTick’. set(Hs_3.65’.25 0.1. plot(w/pi.1. set(gca.65’.0.5]).0. set(gca.0.w_kai. Hs_2 = stem(n.8). set(Hs_2.35.1.0. subplot(’position’. xlabel(’n’).db.6: Filter design plots in Problem 7.0. title(’Apmlitude Response’).’YTickLabel’.’XTickLabel’.8) set(gca.’fontsize’.’XTick’.25 0. title(’Magnitude Response in dB’).Hr. set(gca.13 1 . axis([-1.0.’0.M-1].[0.35’.1).’YTick’.0.1]).1]) set(gca.6.05]).6 0. The filter response plots are shown in Figure 7.35]).M-1].-0.25’.’markersize’.4.’ 1 ’].’0.1]).’0.’fontsize’.Solutions Manual for DSP using Matlab (2nd Edition) 338 2006 subplot(’position’.’XTick’.75 ω/π Figure 7. ylabel(’w_{ham}(n)’).1.25. Hs_3 = stem(n.min(hd)-0.65.8) set(gca. Kaiser Window Ideal Impulse Response 1 0. set(gca.’fontsize’.[0. subplot(’position’.0.1].’fontsize’.[’ 0 ’.-As-30.35.grid.’YTick’.35]). axis([0.4.6. ylabel(’Amplitude’). set(gca.25.1.75.[0.0.0.75 1 0 0 0. set(gca.75’.’0.35]).25.1.[0.2 0 0 0 56 0 56 0 n Magnitude Response in dB Apmlitude Response 1 Amplitude 0 Decibels 56 n n 49 0 0.25.’fontsize’.M.0.’XTick’.0.h. ylabel(’Decibels’).09.1.’linewidth’.8).[0.65 0. xlabel(’\omega/\pi’).59.8).’markersize’.-0.0. 01.L] = Ampl_res(h). M = ceil((As-7. ylabel(’h_d(n)’). % Actual Attn Asd = 42 [Hr. subplot(’position’.7.’inches’.08. close all. % lower stopband edge wp1 = 0.25*pi. % passband ripple delta2 = 0. % Actual passband ripple Rpd = 0. % upper stopband edge delta1 = 0.25.w] = freqz_m(h. 0 ≤ ω ≤ 0.* w_kai. % choose odd M M = 49 n = [0:1:M-1]. w_kai = (kaiser(M.35*pi.8693 As = 40.M.0. [db. % upper passband edge ws2 = 0.’NumberTitle’.min(hd)-0.’filled’).[0.35]).65π 0 ≤ |H (e j ω )| ≤ 0.(ws2-wp2))).M)-ideal_lp(wc1. Hs_1= stem(n. % stopband ripple % % Convert to decibels [Rp.’position’.w. % Kaiser Window wc1 = (ws1+wp1)/2. 0.M-1].’markersize’. hd = ideal_lp(wc2.6.0].05. delta_w = pi/500. wc2 = (ws2+wp2)/2.8) axis([-1.’color’.[0.grd.[0.’Name’. xlabel(’n’).hd. % %% Filter Response Plots Hf_1 = figure(’Units’..14’).. % Determine the Window Design Impulse Response and Frequency Response h = hd .1).beta))’.0.1. set(Hf_1.1102*(As-8.’fontsize’.35π ≤ ω ≤ 0.1. % lower passband edge wp2 = 0.M).[1.P.3).delta2) Rp = 0. ’paperunits’.’paperposition’. set(Hs_1.05.0. M = 2*floor(M/2)+1.1]).95 ≤ |H (e j ω )| ≤ 1.0. title(’Ideal Impulse Response’).0.285*tr_width)+1)+1.2006 Solutions Manual for DSP using Matlab (2nd Edition) 339 P7.75π ≤ ω ≤ π clc.’inches’.’P7..65*pi.[0. set(gca.01.’XTick’.pha.7).95)/(2.7.14 Design a linear-phase FIR digital filter using the Kaiser window method to meet the following specifications: 0 ≤ |H (e j ω )| ≤ 0.75*pi.max(hd)+0.4].’off’.25π 0. %% Specifications: ws1 = 0. Rpd = -min(db(ceil(wp1/delta_w)+1:floor(wp2/delta_w))).1033 Asd = floor(-max(db(1:floor(ws1/delta_w)+1))).01. beta = 0.As] = delta2db(delta1. .mag. 0.4]).4238 % tr_width = abs(min((wp1-ws1). ylabel(’Decibels’). set(gca. subplot(’position’.35]).M. axis([-1.75’. axis([-1. title(’Apmlitude Response’).0.59. title(’Magnitude Response in dB’).M.35 ω/π 0.0.1.1).’fontsize’. Hs_2 = stem(n.35]).w_kai.’YTick’.5]).3).[0.35]).65 0.75 1 0 0 0.db. The filter response plots are shown in Figure 7.2 hd(n) Actual Impulse Response −0.[0.[0.0.6.8).35’.[’ 42’. set(gca. set(Hs_2.1).’ 0 ’]).’ 1 ’].35’.’XTick’.65’. set(gca.Hr.’fontsize’.’0.25.2 0 h(n) wham(n) 0. Hs_3 = stem(n.4 0.4.[-Asd.[0.’markersize’. xlabel(’n’).35.[0.1]).’XTick’.1]).h.min(hd)-0.2 0 −0.0.75’.35. set(Hs_3.’linewidth’.4 0 48 0 48 0 n Magnitude Response in dB Apmlitude Response 1 Amplitude 0 Decibels 48 n n 42 0 0.1.35 0.M-1].3).[’ 0 ’.’XTick’. grid.’YTickLabel’.8). xlabel(’n’).74. xlabel(’\omega/\pi’).0.0. ylabel(’Amplitude’). set(gca. plot(w/pi.05]).[0.25.25.’ 1 ’].4 −0. Kaiser Window Ideal Impulse Response 1 0.25’.’0.-0.8).65.’0.’XTickLabel’.’XTick’.1.’YTick’.25’.1]) set(gca.1]). axis([0.-0.4 0.’fontsize’.0.’0.[0.0.grid.2 0 −0.’filled’). ylabel(’w_{ham}(n)’). subplot(’position’.0.’linewidth’.75 ω/π Figure 7. set(gca. axis([0.[’ 0 ’.’fontsize’.8) set(gca. set(gca.75.1.0]).25 0.1.M-1].1.0. title(’Kaiser Window’). plot(w/pi.65.65’.05.7: Filter design plots in Problem 7.6.09. xlabel(’\omega/\pi’).75.1]).’filled’).’fontsize’.0.35]). set(gca.Solutions Manual for DSP using Matlab (2nd Edition) 340 2006 subplot(’position’.0.0.1].0. ylabel(’h(n)’).’YTick’.25 0.’0.1.’XTickLabel’.65 0.-As-30.1. subplot(’position’.0. title(’Actual Impulse Response’).0.’0.25.4.’0.14 1 .41.[0.8) set(gca.7.0.0.[0.max(hd)+0.’0.0.0.’markersize’.[0. P. tr_width = min([w3-w2. % %% Filter Response Plots Hf_1 = figure(’Units’.’position’.26 using the Kaiser window approach with the specifications: Band-1: 0 ≤ ω ≤ 0.5.[0.3).L] = Ampl_res(h). % upper Band-1 edge w3 = 0.4]. . ’paperunits’.max(hd)+0. set(Hs_1.’P7.beta))’. Hs_1= stem(n.95)/(2.’Name’.005. delta_w = pi/500.’inches’. % Band-2 ripple delta3 = 0.w. Asd = floor(-max(db(ceil(w5/delta_w)+1:501))).0*pi.0.25. δ1 = 0.0.4*pi. xlabel(’n’).15’). % choose odd M M = 75 n = [0:1:M-1].0].mag. % Kaiser Window % Determine Ideal Impulse Response wc1 = (w2+w3)/2.7*pi. set(gca. %% Specifications: w1 = 0.35])..w_kai.25. subplot(’position’.’markersize’.5*(ideal_lp(wc2. % Determine the Window Design Impulse Response and Frequency Response h = hd .35]).M)-ideal_lp(wc1.1.1).[0.6. % lower Band-3 edge w6 = 1.001 clc. title(’Ideal Impulse Response’).* w_kai.grd.’inches’.4π ≤ ω ≤ 0..7). % upper Band-2 edge w5 = 0.’fontsize’. ylabel(’h_d(n)’).0. set(Hs_2.01. Band-3: 0.’NumberTitle’.0.’filled’).delta2. M = ceil((As-7.005 δ3 = 0.3π.M)+0. % lower Band-2 edge w4 = 0.[0. wc2 = (w4+w5)/2.’markersize’.0.min(hd)-0.1]).hd.[1.[0.8π ≤ ω ≤ π.pha.’off’.285*tr_width)+1)+1.As] = delta2db(delta1.[0.’filled’).M)). % Band-1 ripple delta2 = 0. w_kai = (kaiser(M.7.M-1].8) axis([-1. Ideal gain = 1.delta3). [Rp. hd = ideal_lp(wc1. [db. close all. subplot(’position’.w5-w4]).7π. Ideal gain = 0. % Band-3 ripple % % Determine Kaiser Window Parameters delta = min([delta1. Band-2: 0.’XTick’. % lower Band-1 edge w2 = 0. % upper Band-3 edge delta1 = 0. Ideal gain = 0.2006 Solutions Manual for DSP using Matlab (2nd Edition) 341 P7..1102*(As-8.’color’. set(Hf_1.15 Design of the staircase filter of Example 7.1.0*pi. Hs_2 = stem(n. M = 2*floor(M/2)+1.0.3).001.01 δ2 = 0.’paperposition’.7.08.0.w] = freqz_m(h.4]).delta3]). beta = 0.6.3*pi.M.41.8*pi.0. % Actual Attn Asd = 65 [Hr. [0.0.26 has the length of 49. xlabel(’\omega/\pi’).8).25.grid.2 0 0 0 0 74 0 74 0 74 n n n Magnitude Response in dB Apmlitude Response 1 Decibels Amplitude 0 0.[0. xlabel(’n’).’filled’).1. ylabel(’w_{ham}(n)’).0.3 0.1]).35]).0.5 65 0 0 0.8: Filter design plots in Problem 7. set(gca.0.’XTick’.1. set(gca.Hr. ylabel(’Decibels’).0.[0.8.’linewidth’. title(’Apmlitude Response’).1).6 Actual Impulse Response 0.M-1].1.8 1 .0. ylabel(’h(n)’). title(’Kaiser Window’).’fontsize’.’linewidth’.35]).[0.1]. plot(w/pi.max(hd)+0.4 0.2 h(n) wham(n) hd(n) 0.7.Solutions Manual for DSP using Matlab (2nd Edition) 342 2006 axis([-1.0.’XTick’.0.’XTick’.h.8). axis([-1.5. subplot(’position’.05]).-0. The window-designed filter has the length of 75 while the one designed in Example 7.0.-0.15 0.M-1].3.8 1 0 0. set(gca.6 1 0.4.0.4.6.3.1]).[-Asd. title(’Actual Impulse Response’).59. set(gca. set(gca.3 ω/π 0. set(gca.74.1]).1).’ 0 ’]).1. subplot(’position’.db.1. The filter response plots are shown in Figure 7.[0. plot(w/pi.’YTick’. title(’Magnitude Response in dB’).0. axis([0.7 0.4 0.’YTick’. set(gca.[’ 65’. Hs_3 = stem(n.1.-As-30.[0.[0.05.M.1.3). xlabel(’\omega/\pi’).8).’YTick’.0]). grid.5]). xlabel(’n’).0.0.1]).35]).M.’markersize’.7. ylabel(’Amplitude’). Kaiser Window Ideal Impulse Response 0.’fontsize’. axis([0.0.4 0.’XTick’.1]).8. set(Hs_3.[0.0.1.09.0.4.0. subplot(’position’.4.4 0.’YTickLabel’.8. set(gca.[0.0.7 ω/π Figure 7.’fontsize’.min(hd)-0. 1102*(As-8.mag.7.* w_kai.0.delta2] = db2delta(Rp.beta))’.’paperposition’. . ’paperunits’.pha.[0.7).0. % Actual Attn Asd = 40 [Hr. delta_w = pi/500.’inches’..0.[0. % upper passband edge ws2 = 0. M = 2*floor(M/2)+3.08. M = ceil((As-7.[0..5*pi. if (delta1 < delta2) delta2 = delta1.4π R p = 0.7.6*pi. w_kai = (kaiser(M. % Determine the Window Design Impulse Response and Frequency Response h = hd .’P7.L] = Ampl_res(h).16 Design of a bandpass filter using the Kaiser window design technique that has the minimum length and that satisfies the following specifications:  lower stopband edge = 0.5.[1.95)/(2.w.’position’.4].delta2) end % Determine Kaiser Window Parameters tr_width = abs(min((wp1-ws1).’color’. % passband ripple As = 40. % stopband attenuation % % Select the min(delta1.6. % Kaiser Window % Determine Ideal Impulse Response wc1 = (ws1+wp1)/2.As] = delta2db(delta1.3*pi.grd.(ws2-wp2))).w] = freqz_m(h.6π  lower passband edge = 0.P.1.16’). hd = ideal_lp(wc2. % lower passband edge wp2 = 0. % choose odd M M = 49 n = [0:1:M-1]. subplot(’position’.As). set(Hf_1.delta2) since delta1=delta2 in windodow design [delta1. disp(’Delta1 is smaller than delta2’) [Rp.1872 Asd = floor(-max(db(1:floor(ws1/delta_w)))). Rpd = -min(db(ceil(wp1/delta_w)+1:floor(wp2/delta_w))). % lower stopband edge wp1 = 0.25.4]).3π As = 40 dB upper stopband edge = 0.5π clc. % %% Filter Response Plots Hf_1 = figure(’Units’. [db.’off’. upper passband edge = 0.’inches’.5 dB.2006 Solutions Manual for DSP using Matlab (2nd Edition) 343 P7. wc2 = (ws2+wp2)/2. close all.’NumberTitle’.0].0.M).0.’Name’.. % Actual passband ripple Rpd = 0. beta = 0. %% Specifications: ws1 = 0.285*tr_width)+1)+1.35]).1). % upper stopband edge Rp = 0.M)-ideal_lp(wc1.4*pi. ’XTick’.[0.3).5.4.0.M.1].4 0. ylabel(’h(n)’).’YTick’.3 0. plot(w/pi. title(’Magnitude Response in dB’).w_kai.35]).’filled’).6.max(hd)+0.M.6 1 .1.8) axis([-1.-0.1]).2 −0.[0.6.’XTick’.M-1].5 ω/π 0.’fontsize’.05.-0.5 ω/π 0. set(Hs_1.’fontsize’.0]).0.1.3). subplot(’position’. ylabel(’h_d(n)’).0.’markersize’.4.[0.max(hd)+0. set(gca. subplot(’position’. set(gca.6.[0. The filter response plots are shown in Figure 7. Kaiser Window Ideal Impulse Response Actual Impulse Response 0. xlabel(’\omega/\pi’).’YTickLabel’.1.’ 0 ’]).’filled’).9.3 Figure 7.9: Filter design plots in Problem 7.’fontsize’.2 hd(n) 0. axis([-1.3.0.35]). set(Hs_2.’XTick’.1]).1.’XTick’.1]) set(gca.[0.1. title(’Actual Impulse Response’).h.1 0 h(n) wham(n) 0.0. subplot(’position’.[0. subplot(’position’.0. set(gca.min(hd)-0.4 0.0.’markersize’.6. xlabel(’\omega/\pi’).1]). xlabel(’n’).0. set(gca.1). set(Hs_3.8).35]).min(hd)-0.0.5]).3.[0. set(gca.8).’YTick’.0.Hr.[0.’linewidth’.[0.1 −0. grid.25.1 0. xlabel(’n’).3).41.59. ylabel(’Amplitude’). title(’Ideal Impulse Response’).’markersize’.1]).1. Hs_2 = stem(n.3 0. title(’Kaiser Window’). plot(w/pi.M-1].’XTick’.-As-30. xlabel(’n’). axis([0.0.0.1.grid. set(gca. title(’Apmlitude Response’). ylabel(’Decibels’).[-Asd.2 0 0 48 0 48 0 n Magnitude Response in dB Apmlitude Response 1 Amplitude 0 Decibels 48 n n 40 0 0 0.M.8).4.M-1].0. Hs_3 = stem(n.2 −0.’linewidth’. axis([-1.1]).’fontsize’.[0.09. ylabel(’w_{ham}(n)’).74.4.1).35]).6 1 0 0. set(gca.16 0.25.1 0 −0.0.db.0.1.0.0.’filled’).[’ 40’.0.[0.05]). axis([0.0.0.’YTick’.5.Solutions Manual for DSP using Matlab (2nd Edition) 344 2006 Hs_1= stem(n.hd.1.3 1 0. set(gca. ’bandpass’. xlabel(’n’).max(hd)+0. subplot(2.mag. delta_w = pi/500.’fontsize’. set(Hs_1.1.3).1. Hs_1 = stem(n. % passband ripple As = 40. ’paperunits’.1). set(gca.’markersize’. % stopband attenuation % % Select the min(delta1. % lower passband edge wp2 = 0.3). set(gca. set(Hs_1.2*pi/tr_width).2.M.1]).’fontsize’.[wc1. ylabel(’w_{han}(n)’).’inches’.’position’.M. axis([-1. set(Hf_1.1. xlabel(’\omega/\pi’). %% Specifications: ws1 = 0.55*pi.M-1].1).8) subplot(2.min(hd)-0. axis([0. wc1 = (ws1+wp1)/2.’filled’).1.0.[0.delta2) end % tr_width = min((wp1-ws1).M.2.M). title(’Hann Window’). ylabel(’h_d(n)’) subplot(2.’inches’.-0.2.’filled’).w_han.8) axis([-1.1]).’Name’. ylabel(’h(n)’) subplot(2. % upper passband edge ws2 = 0.’XTick’. Rpd = -min(db((wp1/delta_w)+1:(wp2/delta_w)+1))..17’).6.M-1].wc2]/pi.1030 Asd = floor(-max(db(1:(ws1/delta_w)+1))).6.1.’color’.min(hd)-0. hd = ideal_lp(wc2.0.1]).’off’.’linewidth’.8).’P7.’filled’). set(gca. close all.[0.pha. title(’Actual Impulse Response’).5]).3). % upper stopband edge Rp = 0.-As-30. xlabel(’n’). Hs_1= stem(n.35*pi. set(Hs_1.’fontsize’.1).[0.1]..2). title(’Ideal Impulse Response’).As] = delta2db(delta1.’NumberTitle’.delta2) since delta1=delta2 in windodow design [delta1.’markersize’.grd. % choose odd M M = 43 n = 0:M-1.3)..0].’markersize’.’XTick’. M = 2*floor(M/2)+1.75*pi. if (delta1 < delta2) delta2 = delta1.4).w] = freqz_m(h. [db.2*pi.hd.[0.M-1].[1.4].h.w_han).2006 Solutions Manual for DSP using Matlab (2nd Edition) P7. xlabel(’n’).’YTick’.8) axis([-1. h = fir1(M-1.M)-ideal_lp(wc1.max(hd)+0. title(’Magnitude Response in dB’).’XTick’.1.9 using the fir1 function: clc.4]).’fontsize’.delta2] = db2delta(Rp.(ws2-wp2)).17 Repeat of the Problem P7.As).2. set(gca. % lower stopband edge wp1 = 0.db.’paperposition’. plot(w/pi. w_han = (hann(M))’. ylabel(’Decibels’) 345 . Hs_1 = stem(n. % Actual Attn Asd = 44 % %% Filter Response Plots Hf_1 = figure(’Units’.[0.[0.25. M = ceil(6. % Actual passband ripple Rpd = 0. disp(’Delta1 is smaller than delta2’) [Rp. wc2 = (ws2+wp2)/2. 2 ’.’ 0 ’]).2 0. set(gca. Hann Window Ideal Impulse Response 1 0.[’ 0 ’.0]).35 0.35’.’XTickLabel’.10: Filter design plots in Problem 7.’0.’YTick’.55 ω/π Figure 7.2 0 −0.10.’ 1 ’].8) set(gca.55’.0.’XTick’.35.2 h(n) 42 n Magnitude Response in dB 0 40 −0.’0.2 0 42 n 0 0.’YTickLabel’.’fontsize’.0.4 Decibels 0.grid The filter response plots are shown in Figure 7.55.[-40.Solutions Manual for DSP using Matlab (2nd Edition) 346 2006 set(gca.[0.2.75’.17 0.’0.’0.75 1 .2 0 0 42 0 n Actual Impulse Response 0 0.0.1]) set(gca.4 whan(n) hd(n) 0.[’ 40’.0.75. if (delta1 < delta2) delta2 = delta1.3).3).w_ham. Hs_1= stem(n. title(’Hamming Window’).’YTick’. hd = ideal_lp(pi.2. set(gca.1).6*pi.min(hd)-0. % stopband attenuation % % Select the min(delta1.max(hd)+0.grd. wc2 = (ws2+wp2)/2.2. % Actual Attn Asd = 50 Rpd = -min(db(1:floor(wp1/delta_w)+1)).1).’position’.2).4*pi.4]. Hs_1 = stem(n. % lower stopband edge ws2 = 0. title(’Actual Impulse Response’). delta_w = pi/500.M-1]. axis([-1.[0.3*pi.As).1. % passband ripple As = 50. xlabel(’n’).1. set(Hf_1.0.’markersize’.0435 % %% Filter Response Plots Hf_1 = figure(’Units’.’XTick’.1.6*pi/tr_width). ylabel(’w_{ham}(n)’).4]).As] = delta2db(delta1.’markersize’.M)-ideal_lp(wc2. ylabel(’h_d(n)’) subplot(2.delta2] = db2delta(Rp. set(Hs_1.3).1].M-1].’filled’). set(Hs_1. title(’Ideal Impulse Response’).pha.8) axis([-1.’filled’).1.’off’. set(Hs_1. set(gca. % upper stopband edge wp2 = 0.’fontsize’.1).w] = freqz_m(h.6.’NumberTitle’. ylabel(’Decibels’) .[0.w_ham).delta2) since delta1=delta2 in windodow design [delta1.M.M).[0.4).hd. Asd = floor(-max(db(ceil(ws1/delta_w)+1:floor(ws2/delta_w)+1))).’fontsize’. xlabel(’n’). M = ceil(6.db. set(gca.2006 Solutions Manual for DSP using Matlab (2nd Edition) 347 P7.’markersize’.2.[0. title(’Magnitude Response in dB’). axis([0. plot(w/pi. M = 2*floor(M/2)+1.18 Repeat of the Problem P7. % upper passband edge Rp = 0.M.0.18’).M)+ideal_lp(wc1.’filled’).0].’paperposition’. %% Specifications: wp1 = 0.. close all.’color’.8) subplot(2.mag.[1.delta2) end % tr_width = abs(min((wp1-ws1). xlabel(’n’).[wc1.. [db.’stop’. wc1 = (ws1+wp1)/2.max(hd)+0.’fontsize’.7*pi.[0.min(hd)-0. w_ham = (hamming(M))’.2. set(gca..-As-30.5]).1.’inches’.’XTick’.’P7.M-1]. Hs_1 = stem(n.3).8) axis([-1. % lower passband edge ws1 = 0. subplot(2.h. xlabel(’\omega/\pi’).-0.[0.wc2]/pi.8).(ws2-wp2))). % choose odd M M = 67 n = 0:M-1.’inches’.1]).’fontsize’.1]).6. % Actual passband ripple Rpd = 0.10 using the fir1 function: clc.’XTick’.2.’Name’. ’paperunits’.M. h = fir1(M-1. disp(’Delta1 is smaller than delta2’) [Rp.1.’linewidth’.1]). ylabel(’h(n)’) subplot(2. ’0.4 0.3.8 1 wham(n) 0.6’.4.0.4’.3 0.3’.0]).4 0.7’.[-50.’0.1]) set(gca.’ 1 ’].[’ 50’.2 0 66 n 0 0.’YTickLabel’.0. Hamming Window Ideal Impulse Response 0.’XTick’.8) set(gca.’YTick’.grid The filter response plots are shown in Figure 7.0.’0.18 1 . set(gca.11.7.’XTickLabel’.6.’0.6 0.4 d h (n) 0.’ 0 ’]).11: Filter design plots in Problem 7.Solutions Manual for DSP using Matlab (2nd Edition) 348 2006 set(gca.[’ 0 ’.2 0 66 0 n Actual Impulse Response 66 n Magnitude Response in dB 0.2 50 0 −0.[0.0.8 0 0.’fontsize’.6 Decibels h(n) 0.6 0.2 0 0 −0.7 ω/π Figure 7. axis([-1.3).’P7.w] = freqz_m(h. set(Hs_1. wc1 = (ws1+wp1)/2. w_ham = (hamming(M))’.grd.(ws2-wp2))). [db.[1. ylabel(’w_{ham}(n)’). ’paperunits’.[0.5*pi.max(hd)+0.M.2.2. set(gca.5.1.M.mag. % passband ripple As = 50.min(hd)-0.’inches’. delta_w = pi/500. M = 2*floor(M/2)+1.1.4). set(Hf_1.’off’. ylabel(’Decibels’) .delta2] = db2delta(Rp.M-1]. title(’Ideal Impulse Response’).h.hd.’fontsize’.1.1.1). ylabel(’h_d(n)’) subplot(2.8) axis([-1.[wc1.1). set(Hs_1. close all.2).8) axis([-1.As] = delta2db(delta1.’Name’. Hs_1 = stem(n.’fontsize’.[0.max(hd)+0.0]. xlabel(’n’).’inches’.’markersize’. set(gca.M-1].1).6*pi. title(’Magnitude Response in dB’). title(’Hamming Window’).4]. % Actual Attn Asd = 51 % %% Filter Response Plots Hf_1 = figure(’Units’.’filled’). M = ceil(6.8) subplot(2. plot(w/pi. wc2 = (ws2+wp2)/2.’XTick’.[0.’bandpass’.0488 Asd = floor(-max(db(1:(ws1/delta_w)+1))).delta2) end % tr_width = abs(min((wp1-ws1). Rpd = -min(db(ceil(wp1/delta_w)+1:floor(wp2/delta_w)+1)).[0.As). % lower passband edge wp2 = 0.’filled’).w_ham. h = fir1(M-1.’XTick’.wc2]/pi.0.3).M)-ideal_lp(wc1.3).M.M). set(gca. xlabel(’n’).11 using the fir1 function: clc.’fontsize’.1. if (delta1 < delta2) delta2 = delta1.3*pi. % upper stopband edge Rp = 0.. % upper passband edge ws2 = 0.db.’color’. Hs_1 = stem(n.1]. set(gca.pha.6*pi/tr_width). subplot(2. hd = ideal_lp(wc2. % stopband attenuation % % Select the min(delta1.w_ham).1]). set(Hs_1.3).. ylabel(’h(n)’) subplot(2.’YTick’. % Actual passband ripple Rpd = 0.19’).6.2. title(’Actual Impulse Response’).min(hd)-0.1]).2006 Solutions Manual for DSP using Matlab (2nd Edition) 349 P7. % choose odd M M = 67 n = 0:M-1.1.8).’linewidth’. %% Specifications: ws1 = 0.’NumberTitle’.’XTick’. Hs_1= stem(n.’markersize’.’markersize’.2.5]).-As-30.19 Repeat of the Problem P7.M-1].4*pi.’paperposition’.[0.0.’fontsize’. xlabel(’\omega/\pi’).’position’.delta2) since delta1=delta2 in windodow design [delta1.1]).-0.6. xlabel(’n’).’filled’).4])..[0. axis([0. % lower stopband edge wp1 = 0. disp(’Delta1 is smaller than delta2’) [Rp. ’fontsize’.2 0 66 n 0 0.3’.0]).12.1 50 −0.1]) set(gca.5.3 1 0.’YTickLabel’. set(gca.12: Filter design plots in Problem 7.grid The filter response plots are shown in Figure 7.’0.’0.[0.2 0 0 66 0 n Actual Impulse Response 66 n Magnitude Response in dB 0.[’ 0 ’.1 0 −0.2 Decibels h(n) 0.6.’0.19 1 .3.3 0.’XTickLabel’.0.Solutions Manual for DSP using Matlab (2nd Edition) 350 2006 set(gca.0.6 ω/π Figure 7.’ 1 ’].’YTick’.[-50.’XTick’. Hamming Window Ideal Impulse Response 0.6’.2 wham(n) d h (n) 0.’ 0 ’]).3 0 0.[’ 50’.5 0.4’.4 0.4.1 −0.’0.0.0.1 0 −0.8) set(gca.5’. mag.[’-0.0039 Asd = floor(-max(db(1:(ws/delta_w)+1))).[1.13.’position’. delta_w = pi/500.1.1.pha.[0.6’.grd.2006 Solutions Manual for DSP using Matlab (2nd Edition) P7. Rpd = -min(db(ceil(wp/delta_w)+1:floor(pi/delta_w)+1)).’XTickLabel’. % Actual Attn Asd = 71 % %% Zoomed Filter Response Plot Hf_1 = figure(’Units’. hd = ideal_lp(pi.1). % choose odd M M = 55 n = 0:M-1.0.db(301:501).’inches’.’color’.1]) set(gca.delta2] = db2delta(Rp. wc = (ws+wp)/2.[’0.’YTick’.As). disp(’Delta1 is smaller than delta2’) Delta1 is smaller than delta2 [Rp.6.004. set(Hf_1.w] = freqz_m(h.[0. w_blk = (blackman(M))’. h = fir1(M-1.[0. plot(w(301:501)/pi.’NumberTitle’.’linewidth’.4*pi. xlabel(’\omega/\pi’).M)-ideal_lp(wc.005.3]).0040 As = 72.wc/pi.[-0.0]. %% Specifications: ws = 0.’off’.6*pi. M = ceil(11*pi/tr_width).0]). ylabel(’Decibels’) set(gca.20 Repeat of the Problem P7. axis([0.5.’XTick’.w_blk). % passband edge Rp = 0.12 using the fir1 function: clc.’high’. title(’Zoomed Magnitude Response in dB’).004.3]. 351 .5. % passband ripple As = 50. % stopband attenuation % % Select the min(delta1.’paperposition’.’ 1 ’]. % Actual passband ripple Rpd = 0.001]).0.1).0.delta2) Rp = 0. M = 2*floor(M/2)+1.004’. ’paperunits’.’Name’..As] = delta2db(delta1. % stopband edge wp = 0. [db. if (delta1 < delta2) delta2 = delta1.’fontsize’.’ 0 ’]).8) set(gca...grid The zoomed magnitude response plot is shown in Figure 7.’P7.12’).-0. set(gca.M). close all.delta2) since delta1=delta2 in windodow design [delta1.7577 end % tr_width = abs(wp-ws).’inches’.’YTickLabel’.6. 13: Filter design plots in Problem 7.20 .6 1 ω/π Figure 7.004 0.Solutions Manual for DSP using Matlab (2nd Edition) 352 2006 Zoomed Magnitude Response in dB Decibels 0 −0. % %% Filter Response Plots Hf_1 = figure(’Units’.max(hd)+0.2006 Solutions Manual for DSP using Matlab (2nd Edition) 353 P7.’paperposition’. hd = ideal_lp(pi.’XTick’. set(Hs_2.35]). Asd = floor(-max(db(ceil(ws1/delta_w)+1:floor(ws2/delta_w)+1))).’YTick’. % lower stopband edge ws2 = 0.025.[wc1. set(Hf_1...35*pi.M-1].1).w] = freqz_m(h.P.L] = Ampl_res(h).95)/(2.8). xlabel(’n’).’filled’). ylabel(’h_d(n)’).1.005.3).4]).-0.1]).0. set(gca.’stop’.M.65*pi. title(’Ideal Impulse Response’).25.w_kai).1]).[0.beta))’. Hs_1= stem(n.’markersize’.[0. % Actual passband ripple Rpd = 0.6. close all. %% Specifications: wp1 = 0. % upper stopband edge wp2 = 0.min(hd)-0.21 Repeat of the Problem P7.’inches’.4].35]).0492 [Hr.M).7.74.[0.0.1. ’paperunits’.pha. .’fontsize’.08.’color’.2351 % tr_width = abs(min((wp1-ws1).M)-ideal_lp(wc2.’Name’.0.25*pi. % Kaiser Window wc1 = (ws1+wp1)/2. wc2 = (ws2+wp2)/2.7. % Ideal HP Filter h = fir1(M-1.[1.’off’.13 using the fir1 function: clc. subplot(’position’.’inches’.mag.1102*(As-8. subplot(’position’.’filled’). ylabel(’w_{ham}(n)’).w_kai.0]. % upper passband edge delta1 = 0. xlabel(’n’).25.1].As] = delta2db(delta1.0.[0. axis([-1.’fontsize’.35]).0.0.8) axis([-1.[0.25.1.6.[0. Hs_2 = stem(n. % passband ripple delta2 = 0.w.6.’position’. set(Hs_1.’markersize’.’P7.0.1.0. M = 2*floor(M/2)+1..0.M. [db.delta2) Rp = 0. subplot(’position’.wc2]/pi.0. M = ceil((As-7.(ws2-wp2))).41. delta_w = pi/500.hd. % stopband ripple % % Convert to decibels [Rp. title(’Kaiser Window’).’fontsize’. set(gca. set(gca.[0.7).4344 As = 46.’NumberTitle’.’XTick’.21’).3). w_kai = (kaiser(M. % choose odd M M = 57 n = [0:1:M-1].M)+ideal_lp(wc1. beta = 0.M-1]. % Actual Attn Asd = 49 Rpd = -min(db(1:floor(wp1/delta_w)+1)).0.[0.grd.8).75*pi. % lower passband edge ws1 = 0.285*tr_width)+1)+1. 25.’0.0. plot(w/pi.05]). plot(w/pi.’YTick’.4 0.M.75.4.25’.6 0.65 0.’0.0.59.’linewidth’.35 ω/π 0.[0. set(gca.’0.05.75 ω/π Figure 7.db.’markersize’. set(gca.14. set(gca.0.4.’XTick’.0.1]). axis([0. title(’Apmlitude Response’).’YTickLabel’.’0.1).25.35.Solutions Manual for DSP using Matlab (2nd Edition) 354 2006 Hs_3 = stem(n. title(’Magnitude Response in dB’).2 0 0 0 0 56 0 56 0 n Magnitude Response in dB Apmlitude Response 1 Amplitude 0 Decibels 56 n n 49 0 0.’filled’).[-Asd.0.6 0.35]).[’ 0 ’.’0.’ 1 ’]. subplot(’position’.75’.[0.’fontsize’.’ 1 ’]. xlabel(’\omega/\pi’).’fontsize’.’XTick’.0.75’.21 1 .09. ylabel(’Decibels’).’XTickLabel’.1. ylabel(’h(n)’).8) set(gca.1.[0.’0.35]).1.2 h(n) wham(n) 0.’linewidth’.1]) set(gca.1.0.[’ 49’.’XTick’.’0. xlabel(’\omega/\pi’).25’.14: Filter design plots in Problem 7.[0. set(gca.1]).’YTick’.3).0.[’ 0 ’.1]).65’.0.0.35’.25 0.5]).75 1 0 0 0.25 0.M-1].35’.0.min(hd)-0.4 hd(n) Actual Impulse Response 0. grid.grid.’XTickLabel’. title(’Actual Impulse Response’).max(hd)+0.0. Kaiser Window Ideal Impulse Response 1 0.1.’ 0 ’]).0]). axis([-1.75.8). axis([0.[0.65.1).1.0.0.65 0. set(Hs_3. subplot(’position’.Hr.-0.8) set(gca. xlabel(’n’).65’.h. set(gca.’fontsize’. ylabel(’Amplitude’). The filter response plots are shown in Figure 7.65.35.-As-30.35 0.[0.’0. ’inches’.7. axis([-1.41.8). % Actual Attn Asd = 42 [Hr.’fontsize’.As] = delta2db(delta1.75*pi.7). % Kaiser Window wc1 = (ws1+wp1)/2.P.8).[0. [db.7.8) axis([-1. Rpd = -min(db(ceil(wp1/delta_w)+1:floor(wp2/delta_w))).grd.w_kai.beta))’. set(Hf_1. Hs_2 = stem(n.25*pi.1]).w.35]).min(hd)-0.L] = Ampl_res(h).[0.1033 Asd = floor(-max(db(1:floor(ws1/delta_w)+1))).’inches’.[0.3).2006 Solutions Manual for DSP using Matlab (2nd Edition) 355 P7.M)-ideal_lp(wc1. set(Hs_1. set(gca.w_kai).0]..’XTick’. % Determine the Window Design Impulse Response and Frequency Response h = fir1(M-1.25.0.[0.. % stopband ripple % % Convert to decibels [Rp.’filled’). % %% Filter Response Plots Hf_1 = figure(’Units’. xlabel(’n’). set(gca.0. hd = ideal_lp(wc2.1. wc2 = (ws2+wp2)/2.’P7.pha. % Actual passband ripple Rpd = 0.’YTick’.’filled’). % passband ripple delta2 = 0..w] = freqz_m(h. %% Specifications: ws1 = 0.0. beta = 0.08.’markersize’.hd.[0. Hs_1= stem(n. delta_w = pi/500.0. % choose odd M M = 49 n = [0:1:M-1]. title(’Kaiser Window’).35*pi.(ws2-wp2))).4238 % tr_width = abs(min((wp1-ws1). w_kai = (kaiser(M.1]. % upper stopband edge delta1 = 0.’off’.M). title(’Ideal Impulse Response’). close all.4].22 Repeat of the Problem P7. ylabel(’w_{ham}(n)’).[wc1. set(Hs_2.mag.[0.M-1].0. xlabel(’n’).’color’.6.’fontsize’.285*tr_width)+1)+1.1102*(As-8. set(gca.’XTick’.’markersize’.’paperposition’.M-1]. % lower stopband edge wp1 = 0. subplot(’position’.wc2]/pi.65*pi.M.0.’NumberTitle’.25.[1.0.M.-0. % upper passband edge ws2 = 0.14 using the fir1 function: clc.1.95)/(2. M = 2*floor(M/2)+1.max(hd)+0.35]).05. ylabel(’h_d(n)’).8693 As = 40.3).0.’fontsize’.1).1]). % lower passband edge wp2 = 0.1.’position’.6.delta2) Rp = 0.[0.1. subplot(’position’.01.’bandpass’. .22’). M = ceil((As-7.’Name’. ’paperunits’.4]). db.’XTickLabel’.0.2 0 h(n) wham(n) 0.’YTick’.’0.8).M-1].’0. subplot(’position’.35 0.75’.0.’0.8) set(gca.Solutions Manual for DSP using Matlab (2nd Edition) 356 2006 subplot(’position’.0]).35’.4 0 48 0 48 0 n Magnitude Response in dB Apmlitude Response 1 Amplitude 0 Decibels 48 n n 42 0 0.-0.’YTickLabel’. ylabel(’Decibels’).1.25 0.1.65 0.0. plot(w/pi.0.[0.0.15: Filter design plots in Problem 7.grid. set(gca.’YTick’.5]).25.75.2 0 −0. xlabel(’n’).1]).[0.35]).4 0.65’.’fontsize’.59.Hr.’linewidth’.2 0 −0.’XTick’.09.1).0.-As-30.M.75 1 0 0 0. plot(w/pi.’fontsize’.’0.0.2 hd(n) Actual Impulse Response −0.35]).min(hd)-0.0.65 0.’linewidth’. title(’Apmlitude Response’).0. set(Hs_3.1]).75 ω/π 1 . title(’Actual Impulse Response’).4. subplot(’position’. Hs_3 = stem(n. grid.0.[0.35. set(gca.35’.’ 1 ’]. The filter response plots are shown in Figure 7.0. xlabel(’\omega/\pi’).1.1.8) set(gca.75.[’ 42’. axis([0.35.35]).05]).’XTickLabel’.’0.0.[0.0.’0.’XTick’.75’.0. set(gca.1).0.h.25.25’.22 0.1.[’ 0 ’. Kaiser Window Ideal Impulse Response 1 0. set(gca.’filled’).0.[0.’fontsize’.[0.[0.25 0.’0. ylabel(’Amplitude’).65’.’XTick’.05.max(hd)+0. axis([-1.4. ylabel(’h(n)’).[-Asd.1. xlabel(’\omega/\pi’).4 −0.1]).’ 0 ’]).[’ 0 ’.6.65.1]) set(gca. set(gca.4 0.65.35 ω/π Figure 7.25’.3).0.74. title(’Magnitude Response in dB’).15.’0.25. axis([0.’markersize’.’ 1 ’]. 23 Consider an ideal lowpass filter with the cutoff frequency ωc = 0. Determine the minimum stopband attenuation.5 and use the naive design method to compute h(n). (b) Now vary the sample at ωc and determine the optimum value to obtain the largest minimum stopband attenuation.2006 Solutions Manual for DSP using Matlab (2nd Edition) 357 P7. We want to approximate this filter using a frequency sampling design in which we choose 40 samples. (c) Plot the magnitude responses in dB of the above two designs in one plot and comment on the results.3π . (a) Choose the sample at ωc equal to 0. . 58753. ylabel(’Decibels’).’g’.zeros(1. clc. % Filter Response Plots subplot(’position’. % Ideal Amplitude Response for Plotting fc1 = (wp1+ws1)/(2*pi). fc2 = (ws2+wp2)/(2*pi). k = 0:M-1. set(Hp_1.’mo’).8). k2 = floor((M-1)/2)+1:M-1.’xtick’.[0.[0.wp2.pi]/pi. set(gca.T1. set(gca.1]).’xgrid’.ws1. plot(w/pi.0].’markersize’. wk = (2*pi/M)*k. ’paperunits’.0..ws2.ws1. % upper stopband edge wp2 = 0.’Name’.’paperposition’.24 Design of the bandstop filter of Problem P7.Hdr.0.11).1. xlabel(’\omega/\pi’).3).1..’xgrid’.10508. % Samples of the Frequency Response T1 = 0.T2.3*pi. hold on.4. fdr = [0..T1.1]. title(’Frequency Sampling Design: Magnitude Plot’).2). H = Hrs.1.[0. % stopband attenuation Hf_1 = figure(’Units’. ylabel(’Magnitude’)..wp1.59.’xtick’.10 using the frequency sampling method with two optimum samples in the transition band and comparison of results with those obtained using the fir2 function.1. set(Hf_1. angH = [-alpha*(2*pi)/M*k1.0. . xlabel(’\omega/\pi’).’position’.1.24’).’on’).[0. % lower passband edge ws1 = 0.mag.grd.8).’ytick’.6.0.4. Hrs = [ones(1.T2. % lower stopband edge ws2 = 0.2).ones(1.09. % Specifications: wp1 = 0. set(gca.’inches’.0.0. axis([0.1.’r’.’g’.35]). delta_w = pi/500. plot(w/pi. Hp_1 = plot(wk(1:(M+1)/2)/pi.0.7.10)].[1..2.6. % upper passband edge Rp = 0.1]).0].[0. T1.0.’ytick’.6*pi.wp2. plot(fdr.T1. % passband ripple As = 50.*exp(j*angH).fc1.wp1.0. alpha = (M-1)/2. Hdr = [1.fc2. %% Frequency Sampling Design % Choose M = 65 to get two samples in the transition band M = 65.ws2.’linewidth’. alpha*(2*pi)/M*(M-k2)]. axis([0.-80.35]).T2.20). set(gca.5].pha.1]. % Actual Attn Asd = floor(-max(db(ceil(ws1/delta_w)+1:floor(ws2/delta_w)+1))).7.’on’).’off’. % Compute Frequency Responses [db.T2.[-Asd.’linewidth’.[0.’P7.M)).mag.fc2.’NumberTitle’.fc1. h = real(ifft(H.Hrs(1:(M+1)/2).0.’ygrid’.1).’on’).0.5]).10]).zeros(1. title(’Frequency Sampling Design: Log-Magnitude Plot’). hold off. close all.ones(1. subplot(’position’.358 Solutions Manual for DSP using Matlab (2nd Edition) 2006 P7.. % Compute the Impulse Response k1 = 0:floor((M-1)/2).db.’inches’.’color’.’linewidth’.5). T2 = 0.[0.pi]/pi.7*pi.w] = freqz_m(h.1.4*pi. fc1.set(Hp_2.’ytick’.’xgrid’.’ygrid’.1].1]).w] = freqz_m(h.6 0.7 1 0 0.’linewidth’. The filter response plots are shown in Figure 7. axis([0. ’markersize’. set(gca.[0.7 ω/π Figure 7.3 0.’on’).pi]/pi.16: Filter design plots in Problem 7.0. h = fir2(82.1.1. axis([0.ws1.wp1.’ytick’. title(’FIR2 Function Design: Magnitude Plot’). hold off.3 0.3 0. Hdr = [1.fc2.pha. plot(fdr.ws2.59.0. % Compute Frequency Responses [db.’linewidth’. set(gca.09.1.6 0.’on’).6 0. xlabel(’\omega/\pi’). hold on.[0.0.4.0.Hdr.[0.fdr.’xgrid’.6 0.grd.4 0.’r’.’on’).0].1. title(’FIR2 Function Design: Log-Magnitude Plot’).4.24 1 . xlabel(’\omega/\pi’).3 0.wp2. ylabel(’Magnitude’).35]).1.mag. % Actual Attn Asd = floor(-max(db(ceil(ws1/delta_w)+1:floor(ws2/delta_w)+1))).’mo’).wp1.fc2.’linewidth’.-80.’xtick’.’g’.pi]/pi.10]).4 0. set(gca.1]. % Filter Response Plots subplot(’position’.ws1.7 ω/π 1 0 0.’g’. plot(w/pi. plot(w/pi.5).0.1.35]).7 ω/π ω/π FIR2 Function Design: Magnitude Plot FIR2 Function Design: Log−Magnitude Plot 1 1 Decibels Magnitude 0 −51 0 0 0.fc1.1]). Hp_2 = plot(wk(1:(M+1)/2)/pi. set(gca.mag.wp2.2006 Solutions Manual for DSP using Matlab (2nd Edition) 359 %% Design Using the FIR2 Function fc1 = (wp1+ws1)/(2*pi).[0.’xtick’.4 0. fdr = [0.2).16.1.db.1.Hdr). fc2 = (ws2+wp2)/(2*pi).[0.Hrs(1:(M+1)/2).0.3). ylabel(’Decibels’).ws2.1).2). delta_w = pi/500.0.4 0.0.0.[-Asd. Frequency Sampling Design: Magnitude Plot Frequency Sampling Design: Log−Magnitude Plot 1 Decibels Magnitude 0 −62 0 0 0. subplot(’position’. .25 Design of the bandpass filter of Problem P7.. H = Hrs.ws2.1. set(Hp_1. hold off.0.’P7.0. ylabel(’Magnitude’).0.[0.’color’.TR.7. % Ideal Amplitude Response for Plotting fc1 = (wp1+ws1)/(2*pi).fc1..2).09.[0.’g’.’ytick’. % Samples of the Frequency Response T0 = 1. T1 = 0.1]).[0.4*pi.wp2.23).Hdr.zeros(1. % Actual Attn Asd = floor(-max(db(1:floor(ws1/delta_w)))).’g’.T1.pi]/pi.0].’linewidth’.’inches’.6*pi.0.9). % passband ripple As = 50.10 using the frequency sampling method with two optimum samples in the transition band and comparison of results with those obtained using the fir2 function. close all.5.6.7. plot(w/pi.*exp(j*angH)..’xtick’.10508.’position’.2).’mo’).’r’. set(gca.[0.’on’.pha.pi]/pi.’xgrid’.0.’on’).fc2.’xtick’.fc2.0.[1.0]. % Compute Frequency Responses [db.1). fc2 = (ws2+wp2)/(2*pi). ’markersize’. TL. wk = (2*pi/M)*k.ones(1. axis([0. ’paperunits’.1.2).1. set(gca.’inches’.’paperposition’. % Compute the Impulse Response k1 = 0:floor((M-1)/2).[-Asd. set(gca.’ygrid’. plot(w/pi.’ytick’. angH = [-alpha*(2*pi)/M*k1.T0].35]).’on’). Hrs = [zeros(1.[0.1].’NumberTitle’. % Specifications: ws1 = 0. alpha = (M-1)/2.’Name’. % lower passband edge wp2 = 0.0.35]).[0.360 Solutions Manual for DSP using Matlab (2nd Edition) 2006 P7.10]). T2 = 0. xlabel(’\omega/\pi’).1. xlabel(’\omega/\pi’).59.ws2. alpha*(2*pi)/M*(M-k2)].T2. Hdr = [0. Hp_1 = plot(wk(1:(M+1)/2)/pi.5]).5*pi. fdr = [0.6.’linewidth’. k = 0:M-1.ws1. k2 = floor((M-1)/2)+1:M-1.ones(1. plot(fdr. T3 = 0.0.[0. set(Hf_1..-80.’xgrid’.M)). delta_w = pi/500. h = real(ifft(H.1.w] = freqz_m(h.0.1]). title(’Frequency Sampling Design: Log-Magnitude Plot’).mag. clc..3). %% Frequency Sampling Design % Choose M = 60 to get two samples in the transition band M = 60.0. % lower stopband edge wp1 = 0.25’).5).mag. TL = [T3.’on’).db.2).fc1. % upper stopband edge Rp = 0.wp2.1. % stopband attenuation Hf_1 = figure(’Units’.wp1. title(’Frequency Sampling Design: Magnitude Plot’). hold on.wp1.grd.’ygrid’. TR = fliplr(TL).58753. subplot(’position’.1.4. set(gca.ws1.TR. axis([0. % Filter Response Plots subplot(’position’.4. ylabel(’Decibels’).0.TL.5].. % upper passband edge ws2 = 0.8)].3*pi.Hrs(1:(M+1)/2).’linewidth’.0].’off’.zeros(1. 6 1 0 FIR2 Function Design: Magnitude Plot 0. set(gca.fdr.2). Frequency Sampling Design: Magnitude Plot Frequency Sampling Design: Log−Magnitude Plot 1 Decibels Magnitude 0 −53 0 0 0.Hrs(1:(M+1)/2).0].1.fc2.3 0.’g’.09.wp2. plot(w/pi.ws1.[0.10]). plot(fdr. axis([0.0. xlabel(’\omega/\pi’).’ygrid’.wp2. title(’FIR2 Function Design: Magnitude Plot’).4.’xtick’.’xtick’.wp1.1.0.mag.1.’mo’).25 0.17.35]).5 ω/π 0.6 1 .0.’r’.wp1.ws2. set(gca.fc1.35]).0.1.1.1. % Compute Frequency Responses [db.2).4 0. set(Hp_2. Hp_2 = plot(wk(1:(M+1)/2)/pi.[0.’ytick’. The filter response plots are shown in Figure 7. title(’FIR2 Function Design: Log-Magnitude Plot’).0.4 0.1]).6 1 0 0.’markersize’.mag. Hdr = [0. axis([0. set(gca.’on’).’on’). xlabel(’\omega/\pi’).3 0.’on’).pi]/pi.17: Filter design plots in Problem 7.’linewidth’.4 0. fc2 = (ws2+wp2)/(2*pi). delta_w = pi/500.-80. % Filter Response Plots subplot(’position’.w] = freqz_m(h.0.3).3 0.6 1 FIR2 Function Design: Log−Magnitude Plot 1 Decibels Magnitude 0 −51 0 0 0.1.4 0.3 0.fc1.[-Asd.Hdr.’g’.5).ws2. hold off.1).5 ω/π 0. plot(w/pi.’linewidth’.grd.0.2006 Solutions Manual for DSP using Matlab (2nd Edition) 361 %% Design Using the FIR2 Function fc1 = (wp1+ws1)/(2*pi).1]).4.1].1.0.Hdr).59. subplot(’position’.’ytick’.[0.[0. % Actual Attn Asd = floor(-max(db(1:floor(ws1/delta_w)))). set(gca.5 ω/π 0.ws1. hold on.[0.fc2. ylabel(’Decibels’). fdr = [0. h = fir2(78.0].’ygrid’.db. ylabel(’Magnitude’).’linewidth’.pi]/pi.pha.0.’xgrid’.’on’.5 ω/π Figure 7.’xgrid’. 1].w] = freqz_m(h.6.7.0. close all.0].zeros(1.0].[0.’ygrid’. .mag.-80.2).grd. title(’Frequency Sampling Design: Log-Magnitude Plot’). xlabel(’\omega/\pi’).’on’).35]).1.’color’.58753. %% Frequency Sampling Design % Choose M = 65 to get two samples in the transition band M = 65.40). % Compute the Impulse Response k1 = 0:floor((M-1)/2).’markersize’.’g’.26’). subplot(’position’.fdr.12 using the frequency sampling method with two optimum samples in the transition band and comparison of results with those obtained using the fir2 function.Hrs(1:(M+1)/2).’g’.M)).’ytick’. Hdr = [0. % Actual Attn Asd = floor(-max(db(1:floor(ws/delta_w)))).0.0.10508. % Specifications: ws = 0. alpha*(2*pi)/M*(M-k2)]. ’paperunits’.’on’).26 Design of the highpass filter of Problem P7. k = 0:M-1.Hdr).004.’P7.’r’.1]).1).3*pi.0.’xtick’. % stopband attenuation Hf_1 = figure(’Units’. clc.[0. angH = [-alpha*(2*pi)/M*k1.’paperposition’. set(gca.[-Asd.ws.’NumberTitle’.35]). set(gca. Hrs = [zeros(1.ws.’linewidth’.5).10)]. Hdr = [0. H = Hrs..*exp(j*angH).4.’Name’.5]).7.2). %% Design Using the FIR2 Function fc = (wp+ws)/(2*pi).T1.’linewidth’. set(gca. plot(fdr.’position’.[0. % Compute Frequency Responses [db.59.0.4*pi.pha.’on’). wk = (2*pi/M)*k.wp. plot(w/pi.4.0.’on’.T1. hold on. ylabel(’Magnitude’).1.[1..fc. set(gca.T2.0.1.3). % Ideal Amplitude Response for Plotting fc = (wp+ws)/(2*pi).db. delta_w = pi/500.mag.1]. alpha = (M-1)/2. title(’Frequency Sampling Design: Magnitude Plot’).’xtick’.. h = real(ifft(H. set(Hf_1. hold off.’ygrid’. Hp_1 = plot(wk(1:(M+1)/2)/pi.1].5].’xgrid’. % Passband edge Rp = 0. T2 = 0. fdr = [0. fdr = [0. k2 = floor((M-1)/2)+1:M-1.10]).pi]/pi.ones(1.6. ylabel(’Decibels’). % Stopband edge wp = 0.1]).0.’xgrid’.wp.[0.0.pi]/pi.362 Solutions Manual for DSP using Matlab (2nd Edition) 2006 P7.fc.’mo’).1.’linewidth’. plot(w/pi. set(Hp_1.’ytick’.T2.09.fc.0.’inches’.[0.0.’off’.1.fc.[0.[0. % Filter Response Plots subplot(’position’.Hdr. xlabel(’\omega/\pi’).11). % passband ripple As = 50. axis([0.1]. axis([0. h = fir2(78.1.’inches’. % Samples of the Frequency Response T1 = 0.1. 4 1 ω/π ω/π FIR2 Function Design: Magnitude Plot FIR2 Function Design: Log−Magnitude Plot 1 Decibels Magnitude 0 −50 0 0 0.4.1.3 0.db.1.’on’).3).wp.0.’ytick’.’linewidth’. % Actual Attn Asd = floor(-max(db(1:floor(ws/delta_w)))). set(gca. axis([0.’g’.5).0.2006 Solutions Manual for DSP using Matlab (2nd Edition) 363 % Compute Frequency Responses [db. hold on.grd.[0.’mo’). plot(w/pi.’xgrid’. The filter response plots are shown in Figure 7.pi]/pi.0. Hp_2 = plot(wk(1:(M+1)/2)/pi. set(gca.1.’ygrid’.-80.mag.’on’).2). xlabel(’\omega/\pi’).[0. axis([0.4 1 0 0.mag.’linewidth’. set(gca.[-Asd.18: Filter design plots in Problem 7. % Filter Response Plots subplot(’position’.’ygrid’. subplot(’position’. Frequency Sampling Design: Magnitude Plot Frequency Sampling Design: Log−Magnitude Plot 1 Decibels Magnitude 0 −59 0 0 0.3 0. xlabel(’\omega/\pi’). title(’FIR2 Function Design: Log-Magnitude Plot’).0.1.[0.’markersize’.0].26 1 ω/π . plot(w/pi.ws.[0. plot(fdr.’r’.3 0.pi]/pi.[0.’on’.’xtick’.pha. set(Hp_2.3 0.’g’.09.1.35]).’ytick’. set(gca. ylabel(’Decibels’).2).18. hold off.4 1 0 0. title(’FIR2 Function Design: Magnitude Plot’).59.0.4.1).w] = freqz_m(h.wp.’linewidth’.’xgrid’.Hrs(1:(M+1)/2). delta_w = pi/500.’on’).35]).0.’xtick’.1]).0.ws.1.10]).Hdr.4 ω/π Figure 7. ylabel(’Magnitude’).1]). The bandwidth should be no more than 0. (a) Use the frequency sampling technique and choose M so that there is one sample in the transition band. . (c) Compare the above two filter designs in terms of their implementation and their filtering effectiveness. (b) Use the Kaiser window technique so that the stopband attenuation is same as that of the above frequency sampling design. Use the optimum value for transition band samples and draw the frequency sampling structure.5π .1π . Determine the impulse response h(n) and draw the linear-phase structure.27 We want to design a narrow bandpass filter to pass the center frequency at ω0 = 0.364 Solutions Manual for DSP using Matlab (2nd Edition) 2006 P7. ylabel(’Amplitude’).1.1.0]. The filter amplitude response plot is shown in Figure 7..fdr.35. plot(w/pi.2.02 1.0. % Specifications: fdr = [0.’xgrid’.19.65.’ytick’.28 Frequency sampling design using the fir2 function and a Hamming window.[0.[0. ’paperunits’. Hf_1 = figure(’Units’.2.-0.5). Hdr = [0.65 0.0..1.0. axis([0.’linewidth’. set(Hf_1.’P7. close all. title(’FIR2 Function Design’).’ygrid’.02].0.2..’paperposition’.’r’.75 ω/π Figure 7.05]).’position’.’Name’.Hdr).Hr.05.1.1.[1. clc.0].5.w.25 0.28 1 .P.2.’color’.98.0.’on’).28’).98 1 0 0 0.’inches’.1.’xtick’.’NumberTitle’.35 0.’off’.[0.1. h = fir2(211.19: Filter design plots in Problem 7.’inches’.L] = ampl_res(h). xlabel(’\omega/\pi’).3]).5.’on’.75.25.fdr.3].0.2006 Solutions Manual for DSP using Matlab (2nd Edition) 365 P7. [Hr.1]. set(gca. FIR2 Function Design Amplitude 2. .0].’P7.fc1.1.8]). % stopband attenuation Hf_1 = figure(’Units’. k = 0:M-1.3).1. % Ideal Amplitude Response for Plotting fc1 = (wp1+ws1)/(2*pi).mag.wp2.-0.6)]. axis([0. delta_w = pi/500. % lower stopband edge wp1 = 0. % Specifications: ws1 = 0.’ytick’. subplot(’position’. close all.10]).’markersize’.0]. alpha = (M-1)/2. set(Hs_1.’position’.2.’on’).’NumberTitle’. title(’Impulse Response’). % upper stopband edge Rp = 0. wk = (2*pi/M)*k.zeros(1.4*pi.0.’on’).pi]/pi.0.0. The filter response plots are shown in Figure 7. ’paperunits’.’xtick’.’paperposition’. % Compute the Impulse Response k1 = 0:floor((M-1)/2). H = Hrs.0. Hrs = [zeros(1. set(gca.’off’. n = 0:M-1.’ygrid’..[-Asd. ylabel(’Decibels’).0.pha.’xtick’.[0. plot(w/pi.0].’g’.09.3]).1].’filled’).wp1.M-1]).2). .0. clc. xlabel(’n’).’inches’.ws1. %% Frequency Sampling Design % Choose M = 40 to get one sample in the transition band M = 40.db.[0.M.366 Solutions Manual for DSP using Matlab (2nd Edition) 2006 P7.[0.4.7.T1.20. % lower passband edge wp2 = 0.’inches’. set(Hf_1. % passband ripple As = 40. title(’Log-Magnitude Plot’). Hdr = [0.1.’color’.T1.7. axis([-1.ones(1. Hs_1 = stem(n. alpha*(2*pi)/M*(M-k2)]. ylabel(’Amplitude’). % Samples of the Frequency Response T1 = 0.1.4.8]).w] = freqz_m(h.*exp(j*angH).-80.1.T1.3*pi.59. set(gca.grd.0.’linewidth’.0.29 Design of a bandpass filter using the frequency sampling method with one optimum sample in the transition band and plot of the log-magnitude response in dB and stem plot of the impulse response.7*pi. angH = [-alpha*(2*pi)/M*k1. % Compute Frequency Responses [db.M)).[1..zeros(1. % Filter Response Plots subplot(’position’.1). fdr = [0.[0.6*pi.fc2.fc1.ws2. k2 = floor((M-1)/2)+1:M-1. % upper passband edge ws2 = 0. h = real(ifft(H.0.5.’g’. fc2 = (ws2+wp2)/(2*pi).’xgrid’.7).h.25]).405.[0.0.ones(1.1. set(gca.’Name’.[0.5).3].29’).13). % Actual Attn Asd = floor(-max(db(ceil(ws2/delta_w)+2:end))).0.fc2. xlabel(’\omega/\pi’).5).T1. 25 0.2006 Solutions Manual for DSP using Matlab (2nd Edition) Impulse Response 367 Log−Magnitude Plot 0.15 −0.7 1 .3 0.29 0.2 0 39 0 0.1 0.1 −0.6 ω/π n Figure 7.2 0 0.05 0 −38 −0.20: Filter design plots in Problem 7.05 −0.4 0.15 Decibels Amplitude 0. ’ 0 ’]).4]). ’paperunits’. (b) Plot of the amplitude response of the filter.’linewidth’.1). h = remez(M-1.1).[0.368 Solutions Manual for DSP using Matlab (2nd Edition) P7.f. plot(w/pi.max(h)+0. % lower cutoff frequency wc2 = 2*pi/3.1].0. % Actial ripple % Filter Response Plots Hf_1 = figure(’Units’.’g’.10)..1.’Name’.’NumberTitle’.1.1.0.’inches’.’color’.[0.’color’.Hr.[0.0]). ylabel(’h(n)’.0. wp2 = wc2-tr_width/2.30b’). [db.’paperposition’.3).’NumberTitle’.3]). π/3 ≤ |ω| ≤ 2π/3  0. axis([-1. ylabel(’Decibels’.’g’.. subplot(2. set(gca. % Actual Attn Rpd = -min(db(ceil(wp1/delta_w)+1:floor(wp2/delta_w)+1)).0]. Asd = floor(-max(db([1:floor(ws1/delta_w)+1]))).w. xlabel(’\omega/\pi’..h.’Name’.pha.-80.1. subplot(2.0.0]. Hf_2 = figure(’Units’.’off’.1.10).30 The frequency response of an ideal bandpass filter is given by  0 ≤ |ω| ≤ π/3  0. delta_w = pi/500. title(’Impulse Response: Bandpass’).’P7.36*(M-1)). clc.’inches’. % stopband attenuation M = 25.ws1/pi.12.’P7.f. set(Hs_1. axis([0.0.10.’position’.’fontsize’. Hs_1 = stem(n.. set(gca. % upper cuoff frequency As = 50.’paperposition’. % filter length % % (a) Design tr_width = 2*pi*(As-13)/(14.10) .6.[’-50’.10).4]. [Hr. f = [0.[0.L] = Hr_type1(h).’fontsize’.grid The impulse and log-magnitude response plots are shown in Figure 7.db. ws2 = wc2+tr_width/2. title(’Amplitude Response’. set(Hf_2..’fontsize’.’position’. %% Specifications wc1 = pi/3. close all.grd.[0. % transition width in radians ws1 = wc1-tr_width/2.’g’.wp1/pi.1. title(’Magnitude Response in dB’.6.1.’fontsize’.m).w] = freqz_m(h.[1. 2π/3 ≤ |ω| ≤ π 2006 (a) Design of a 25-tap filter based on the Parks-McClellan algorithm with stopband attenuation of 50 dB. set(Hf_1.a.’markersize’.’linewidth’.5]). ’paperunits’.10).3].6.30a’).0.wp2/pi.mag.’YTickLabel’.6.’fontsize’.’off’.1. n = 0:M-1.ws2/pi.’fontsize’.[1.10). plot(w/pi.2).[-50.min(h)-0.24]).’fontsize’.’XTick’. Hd (e j ω ) = 1.1.’YTick’.5).1]). xlabel(’n’.’XTick’. m = [0.’inches’.1.’filled’).0].’inches’.M. set(gca. wp1 = wc1+tr_width/2.21.5).. 4407 ω/π 0.2 0 0 0.’XTick’.4407 0.226 0.30 xlabel(’\omega/\pi’.22: Filter amplitude response plot in Problem 7.5593 0.axis([0.1.’XTickMode’.4 h(n) 0.1.8 0.226 0.’fontsize’.22.’manual’. ylabel(’Amplitude’. Amplitude Response 1 Amplitude 0.774 1 Figure 7.6 0.4 0.10).-0.1. The amplitude response plot is shown in Figure 7.1]).2 0 12 24 n Magnitude Response in dB Decibels 0 −50 0 0.774 1 Figure 7.21: Filter impulse and log-magnitude response plots in Problem 7.2006 Solutions Manual for DSP using Matlab (2nd Edition) 369 Impulse Response: Bandpass 0.’fontsize’.5593 ω/π 0.30 .10).2 0 −0. set(gca.f). 1.max(h)+0. set(Hs_1. ws1/pi.’position’. M = 43 M = 2*floor(M/2)+1 f = [0. % Actual Attn Asd = 52 n = 0:M-1.pha. h = remez(M-1.mag.’markersize’. % stopband attenuation % % 1. % lower passband edge ws1 = 0.1])..3*pi.’inches’.4].370 Solutions Manual for DSP using Matlab (2nd Edition) 2006 P7. xlabel(’n’. %% Specifications wp1 = 0.6*delta_f)+1).’inches’. ’paperunits’.m.10) .grd.’fontsize’.[1]).’off’.weights).’fontsize’. % lower stopband edge ws2 = 0. % upper stopband edge wp2 = 0.[1]).’filled’).6*pi.’color’. clc. % upper passband edge Rp = 0.10). % passband ripple As = 50.3).31a’).weights).4*pi.1). Hs_1 = stem(n.’NumberTitle’.min(h)-0.f.M. [db.. weights = [delta2/delta1. [db. ws2/pi. Design delta1 = (10^(Rp/20)-1)/(10^(Rp/20)+1).’g’.25.w] = freqz_m(h. delta_w = pi/500. axis([-1. M = ceil((-20*log10(sqrt(delta1*delta2))-13)/(14. ylabel(’h(n)’..[0. wp1/pi.m. m = [1 1 0 0 1 1]. delta2 = (1+delta1)*(10^(-As/20)). subplot(2.10). % Actual Attn Asd = 46 M = M+2 M = 45 h = remez(M-1.grd.w] = freqz_m(h.1.h. delta_w = pi/500.0]. Asd = floor(-max(db([floor(ws1/delta_w)+1:floor(ws2/delta_w)]))).’paperposition’.[0.pha.1.f. Asd = floor(-max(db([floor(ws1/delta_w)+1:floor(ws2/delta_w)]))). wp2/pi. % Filter Response Plots Hf_1 = figure(’Units’. delta_f =min((wp2-ws2)/(2*pi). delta2/delta1]. (ws1-wp1)/(2*pi)). title(’Impulse Response: Bandpass’.’P7.mag.0.6.1. (a) Design using the Parks-McClellan algorithm and a plots of the impulse response and the magnitude response in dB of the designed filter.4]).31 Design of the bandstop filter given in Problem P7.0.7*pi.6. set(Hf_1.’fontsize’.’Name’.[1. 1].10. close all. 3].’inches’.’YTickMode’.[0.w.’off’.1.[0.’manual’.’XTickMode’.10).0.’fontsize’.10) set(gca.10) axis([0. set(gca.grid. ylabel(’Decibels’.24 the total number of extrema in stopband and passbands are equal to 25.1.f).7 1 Figure 7.6.’NumberTitle’.’g’.-60. title(’Magnitude Response in dB’. [Hr.1.’YTickLabel’.1.’color’.6 h(n) 0. The filter response plots are shown in Figure 7.4 ω/π 0.[-50.’fontsize’.3]).[’ 50’.10)..’manual’.1. ylabel(’Amplitude’.[1.2006 Solutions Manual for DSP using Matlab (2nd Edition) 371 set(gca.[0.’XTick’.5).’fontsize’. Since M = 45.1. Then the extrema are L + 2 or L + 3.’YTick’.’XTick’.23: Filter impulse and log-magnitude response plots in Problem 7.’XTickMode’.31 (b) Plot of the amplitude response of the designed filter. axis([0.0]) set(gca.’manual’.5).’fontsize’.-0.1.2). Hence this is a L + 32 = 25 equiripple design.0].’linewidth’.’g’.db. set(Hf_2. Impulse Response: Bandpass 0.’position’.L] = Hr_type1(h). Hf_2 = figure(’Units’.’Name’.’manual’.23.10) xlabel(’\omega/\pi’.’fontsize’..5]).’ 0 ’]). title(’Amplitude Response’.2 0 17 34 n Magnitude Response in dB Decibels 0 50 0 0.’paperposition’.31b’).’XTickMode’.’P7.6 0.3 0. L = 22.4 0. .a.Hr. plot(w/pi. plot(w/pi. The amplitude response plot is shown in Figure 7..2 0 −0.6.0. set(gca.f).17. xlabel(’\omega/\pi’.’inches’.’linewidth’.’XTick’.10). From Figure 7.24. ’paperunits’.34]) subplot(2.1.1]).’fontsize’. 6 0.’g’. ’paperunits’..10).’Name’.10). Hs_3 = stem(n(1:101). set(Hs_3. ylabel(’x(n)’.10).11]).’fontsize’.4]).’inches’. set(Hf_3.4 ω/π 0.0. axis([0.[0.’fontsize’.’inches’. The input and output signal plots are shown in Figure 7.’fontsize’.100.’g’. y = filter(h.’markersize’. set(Hs_4.[1.1. title(’Output Signal’.’fontsize’.0.[0.1.’markersize’. Hf_3 = figure(’Units’.’fontsize’.-1. x = 5 . xlabel(’n’.3 0. 2 0 ≤ n ≤ 300 n = 0:300.1).’fontsize’. Hs_4 = stem(n(1:101).4].10).-1.1.7 1 Figure 7.6.y(1:101).31c’).3). xlabel(’n’.’position’. (d) Operation of the designed filter on the following signal πn  x(n) = 5 − 5 cos . title(’Input Signal’.1. subplot(2.3). ylabel(’y(n)’.24: Filter amplitude response plot in Problem 7.2 0 0 0.31 (c) The filter order in Problem P7.’off’.’paperposition’.100.0].x(1:101).2).’color’.8 0.6.’NumberTitle’.25. subplot(2. The order using Parks-McClellan algorithm is 44.10)..’filled’).Solutions Manual for DSP using Matlab (2nd Edition) 372 2006 Amplitude Response 1 Amplitude 0.10 is 67 − 1 = 66 while that in P7.x).4 0. axis([0.11]). .5*cos(pi*n/2).10).6 0.’P7..14 is 49 − 1 = 48.’filled’). 2006 Solutions Manual for DSP using Matlab (2nd Edition) 373 Input Signal 10 x(n) 8 6 4 2 0 0 10 20 30 40 50 60 70 80 90 100 70 80 90 100 n Output Signal 10 y(n) 8 6 4 2 0 0 10 20 30 40 50 60 n Figure 7.25: Input/output signal plots in Problem 7.31 . ’off’.25π n) From the Figure 7. ’paperunits’. Therefore.6.9π and plot of the impulse response and the amplitude response: clc.’fontsize’.’fontsize’. title(’Input-Output Sequences’. m = [41:1:81].81]). n=[0:1:100].f.’g’.1*pi.’paperposition’.’YTick’.2]).2).25.mag..’YTick’.10).3]. The filter input-output plots are shown in Figure 7.10).2.1.’color’. close all.9*pi.125. ylabel(’Amplitude’.’fontsize’.5).0].m. with slope equal to 1 sample/cycle.’m’.24].’off’.’filled’).’inches’.0.’color’. Hr. the gain at ω = 0. (b) Verification of the filter performance using 100 samples of the sinusoid x(n) = 3 sin(0.3]).’g’.1). n = 0.10). set(Hs_1.L] = ampl_res(h).[1. Since the slope is π/2 sam/rad.w.’fontsize’. plot(m.’inches’.’differentiator’).1.[0.4]).’XTick’. subplot(2.’P7. grid. set(gca. Hf_1 = figure(’Units’.1π and 0.0.10)..’XTick’.P.x(41:1:81).w1/(2*pi).[0.3]). ylabel(’h(n)’.31a’).y(41+12:1:81+12).4].10).25π n).’NumberTitle’.[0. set(gca.-4. h = firpm(M-1. grid.374 Solutions Manual for DSP using Matlab (2nd Edition) 2006 P7.32 Design a 25-tap FIR differentiator using the Parks-McClellan algorithm.25π is equal to 0..6. .5).1. plot(w/(2*pi). axis([-1.. Hs_1 = stem([0:1:M-1].27.1.’position’. (a) Frequency band of interest between 0.0.25*pi*n).’position’.0.12. title(’Amplitude Response’.10).[0.26.0.’P7..-0. 100 %% (b) Differentiator verification Hf_1 = figure(’Units’.’Name’.w] = freqz_m(h.6. .’fontsize’. set(gca...h.27 we can verify that y (n)(the lower curve) is indeed a cosine waveform with amplitude ≈ 0.’fontsize’..’fontsize’.pha.5]).0.. %% Specifications M = 25.’g’. set(gca.4]). [db. set(Hf_1.5]).5]).[0. set(gca. w1 = 0.[41.0.-h). % slope = 1 sam/cycle % % (a) Design f = [w1/pi w2/pi]. subplot(2. [Hr.1.’paperposition’. set(Hf_1.0. m = [w1/(2*pi) w2/(2*pi)].’fontsize’. % add 12 sample delay to y xlabel(’n’. title(’Impulse Response’.82.’markersize’.6. w2 = 0. x = 3*sin(0. y = conv(x.[-3.’inches’.1.’NumberTitle’.[0. axis([40.0.grd.10). xlabel(’n’.10). ’paperunits’.0.5...3). The filter impulse and amplitude response plots are shown in Figure 7..’linewidth’..m.125) cos (0.0].[0. ’linewidth’. axis([0.31b’).’XTick’.1).’Name’. the output (when properly shifted) should be y (n) = 3 (0.25π n) = 0.w2/(2*pi).’inches’.4.375 cos (0.[1. 05 0.26: Filter impulse and amplitude response plots in Problem 7.2006 Solutions Manual for DSP using Matlab (2nd Edition) 375 Impulse Response 0.5 Figure 7.2 0 12 n Amplitude Response 24 0.32 Input−Output Sequences Amplitude 3 0 −3 41 81 n Figure 7.5 0 0 0.32 .1 −0.27: Filter input-output plots in Problem 7.1 0 −0.45 0.2 h(n) 0. 13.max(h)+0. Asd = floor(-max(db([(0.0. [db.mag..0.0.4]).95. delta3/delta2. subplot(2.10).’off’.m.1. [db.1]).mag.6*delta_f)+1) M = 23 h = firpm(M-1.’Name’.376 Solutions Manual for DSP using Matlab (2nd Edition) 2006 P7.1). weights = [delta3/delta2.33’).m.w] = freqz_m(h.pha.[0.1).33 and plots of its amplitude and impulse responses. axis([-1.m.f. Asd = floor(-max(db([(0.4]..[0. delta3/delta3]. As = -20*log10(0.10). Asd = floor(-max(db([(0. % Actual Attn Asd = 26 n = 0:M-1. % Transition width in cycles per sample M = ceil((-20*log10(sqrt(delta2*delta3))-13)/(14. ’paperunits’. delta1 = 0.M.’NumberTitle’.’position’.025.w] = freqz_m(h.6. title(’Impulse Response’.1).’markersize’.grd.weights).025].10). ylabel(’h(n)’.0.5. Hs_1 = stem(n. [db. xlabel(’n’.weights).05.1).1. set(Hf_1.1].’fontsize’.4.7.8*pi/delta_w)+1:501]))).0. % Actual Attn Asd = 25 M = M+2 M = 27 h = firpm(M-1.0. %% Specifications f = [0.05) As = 26.’XTick’. m = [0.6.4.f. delta3 = 0.8*pi/delta_w)+1:501]))).’color’.w] = freqz_m(h.h.0.33 Design of a lowest order equiripple linear-phase FIR filter to satisfy the specifications given in Figure P7.[1.05.weights).1.0. delta_w = pi/500.0206 % Design delta_f = 0.05.[0.’P7.pha.’filled’).’fontsize’.pha.min(h)-0.0].4. % Actual Attn Asd = 24 M = M+2 M = 25 h = firpm(M-1.’inches’.’paperposition’..f. delta2 = 0.95.0.0.0.’inches’.8.8*pi/delta_w)+1:501]))).025. clc.grd.26]) % Amplitude Response Plot . % Filter Response Plots Hf_1 = figure(’Units’.’fontsize’.grd. close all. set(gca.3). set(Hs_1.’g’.mag. 1]).33 1 .L] = Hr_type1(h).9.’fontsize’.28: Filter amplitude and impulse response plots in Problem 7.05 0 0 0.45 0. ylabel(’Hr(w)’.05.10).0.28.4 0.2).10) set(gca.[0.2006 Solutions Manual for DSP using Matlab (2nd Edition) 377 [Hr.0.’linewidth’.0.5 ω/π 0. plot(w/pi.5). subplot(2.’g’.35 0.8 Figure 7.35.2 0 13 26 n Amplitude Response Hr(w) 1 0.2 0 −0. title(’Amplitude Response’.’fontsize’.’XTick’.’YTick’.45. grid The filter amplitude and impulse response plots are shown in Figure 7.7 0.Hr. Impulse Response h(n) 0.f. axis([0.1.1]) xlabel(’\omega/\pi’.1.4 0.0.’fontsize’.9 0.10).1.0.w.a. F.5*pi.02*pi.1). % Order of the filter w0 = 0.w]=freqz_m(h. The only parameters that we don’t know are the stopband cutoff frequencies ωs1 and ωs2 . % Actual Attn Asd = 13 % Next iteration Deltaw = Deltaw+0.pha. [db.01π. Then ω p1 = ωc − 0.01π. delta_w = pi/500. h=remez(50. ωs1 = ω p1 − 1ω. Asd = floor(-max(db([1:floor(ws1/delta_w)]))). wp2 = w0+Bandwidth/2.02*pi.grd. bandwidth of 0. and ωs2 = ω p2 + 1ω We will also assume that the tolerances in each band are equal.02π .m).w]=freqz_m(h.mag. ws1=wp1-Deltaw. m=[0. wp2.0].m). wp1. ws2=wp2+Deltaw.grd.5π . Let the transition bandwidth be 1ω and let the passband be symmetrical with respect to the center frequency ωc . % Actual Attn Asd = 20 % Next iteration . pi]/pi. h=remez(50.1.01*pi. ws2=wp2+Deltaw.378 Solutions Manual for DSP using Matlab (2nd Edition) 2006 P7. % Bandwidth % % Deltaw = Transition bandwidth (iteration variable) % wp1 = w0-Bandwidth/2. [db. ws2. % (a) Design Deltaw = 0. pi]/pi. F=[0. and stopband attenuation of 30 dB.34 Narrow bandpass filter design using Parks-McClellan Algorithm: We want to design a 50th-order narrowband bandpass filter to filter out noise component with center frequency of ωc = π/2. wp2. Asd = floor(-max(db([1:floor(ws1/delta_w)]))). Matlab Script: clear.1. %% Specifications N = 50.2π and run the firpm algorithm to obtain the actual stopband attenuation.F. (a) In this design we already know the order of the filter.mag. ws1. Now we will begin with initial value for 1ω = 0. ω p2 = ωc + 0. % Center frequency Bandwidth = 0. ws2. wp1.0. F=[0. delta_w = pi/500.0. close all. If it is smaller (larger) than the given 30 dB then we will increase (decrease) 1ω then iterate to obtain the desired solution. ws1. % Initial guess ws1=wp1-Deltaw. The desired solution was found for 1ω = 0.1).pha. x = 2*cos(pi*n/2)+randn(1.pha.0.’Name’. ’paperunits’. % Actual Attn Asd = 30 Hf_1 = figure(’Units’. ws2. Hs_2 = stem(n(101:201). (b) The time-domain response of the filter. wp2.’fontsize’. Asd = floor(-max(db([1:floor(ws1/delta_w)]))).’inches’.201).’off’.’inches’.30.10).0.’linewidth’.’fontsize’. ylabel(’DECIBELS’.’NumberTitle’.3)..m).3]). ws2=wp2+Deltaw.’markersize’.’fontsize’.0]) set(gca.’color’. wp1.F.’paperposition’.1. Hs_1 = stem(n(101:201).01*pi.34b’).m).[1.’m’. pi]/pi.’off’.1.’markersize’. set(Hs_2.10).x(101:201). % Actual Attn Asd = 26 % Next iteration Deltaw = Deltaw+0. Matlab script: % (b) Time-domain Response n = [0:1:200].’fontsize’. xlabel(’n’.1). title(’Input sequence x(n)’.5). plot(w/pi. ylabel(’Amplitude’.1.1. set(Hf_1. F=[0.[0.y(101:201).10).mag.0. delta_w = pi/500.29. ylabel(’Amplitude’.6.pha. subplot(2.1. xlabel(’\omega/\pi’.’YTick’. subplot(2. set(Hf_1. y = filter(h.w]=freqz_m(h. Hf_1 = figure(’Units’.’filled’).’inches’. set(Hs_1.x)... ws2. 379 .[0.grd. ws1=wp1-Deltaw.10).4].3).1).[1. title(’Log-Magnitude Response’.’position’.[-30.3].0]). [db.[’ 30’.ws2/pi.’fontsize’. title(’Output sequence y(n)’. wp2.[0.2006 Solutions Manual for DSP using Matlab (2nd Edition) Deltaw = Deltaw+0. Asd = floor(-max(db([1:floor(ws1/delta_w)]))).’g’.[0.6.w]=freqz_m(h.0].’fontsize’.’NumberTitle’. axis([0.db. ws1. ’paperunits’..0].’inches’. h=remez(50.’ 0 ’]). F=[0. pi]/pi.’g’.’P7.grd.6.mag.’paperposition’.6. h=remez(50. wp1.’filled’).’P7.10) set(gca. ws1=wp1-Deltaw.01*pi. [db.ws1/pi.grid The log-magnitude response is shown in Figure 7.1). ws1.34a’).’XTick’.’YTickLabel’.’Name’.0.4]).’fontsize’.2).1.10).-50.F.1].10).’color’..10). ws2=wp2+Deltaw..’position’. delta_w = pi/500.[0.1.’fontsize’. The time-domain response is shown in Figure 7. 56 1 Figure 7.34b .34a Input sequence x(n) Amplitude 5 0 −5 100 110 120 130 140 150 160 170 180 190 200 170 180 190 200 Output sequence y(n) Amplitude 4 2 0 −2 −4 100 110 120 130 140 150 160 n Figure 7.Solutions Manual for DSP using Matlab (2nd Edition) 380 2006 Log−Magnitude Response DECIBELS 0 30 0 0.30: The Time-domain Response in Problem P7.44 ω/π 0.29: Log-Magnitude Response Plot in Problem P7. 5π ≤ |ω| ≤ π Plot the amplitude response over −π ≤ ω ≤ π .5π stopband : 0.35 Design an equiripple digital Hilbert transformer for the following specifications: passband : 0.2006 Solutions Manual for DSP using Matlab (2nd Edition) P7.01 381 .1π ≤ |ω| ≤ 0.01 ripple δ2 = 0. ripple δ1 = 0. 0.’xtick’. The amplitude response is shown in Figure 7.x).’inches’.’g’.’position’. Hf_1 = figure(’Units’.’color’.0. plot(w/pi.6.36a’). ’paperunits’.65. 0 ≤ n ≤ 100.2.’paperposition’.1].10).0].5).3].5*pi*n)+cos(pi*n).0]..’NumberTitle’.2.grd.6. Amplitude Response Amplitude 2 1 0 0.’paperposition’.0.1: clc.0. (a) Design and plot of the amplitude response with grid-lines and axis labeling as shown in Figure P7.75. set(Hf_1.25.’off’.31: Amplitude Response Plot in Problem P7.[0.36 Design of a minimum order linear-phase FIR filter.10). x2 (n) = cos(0. title(’Amplitude Response’.’Name’.1. grid..’fontsize’.1.w] = freqz_m(h.0. x = 1*cos(0. % Optimum Design h = remez(46.[0. ylabel(’Amplitude’.6.31.0.’inches’.65 0.10).[1.’fontsize’.’linewidth’.25*pi*n)+0*cos(0.’fontsize’. ’paperunits’.[1. x3 (n) = cos(0.1).mag.36a (b) Verification of the filter performance using the following signals x1 (n) = cos(0.6.25 0.. close all.. y = filter(h. [db.[0.mag.1.’inches’.1.2]). .5π n).75π n).2.[1.’color’.4]).25π n).0.’P7. % Specifications f = [0.f. xlabel(’\omega/\pi’.0.3]).35 ω/π 0.f.’inches’.1. % Input/Output Responses n = 0:100.1.1.2]).[0.Solutions Manual for DSP using Matlab (2nd Edition) 382 2006 P7.0. m = [0.. using the Parks-McClellan algorithm..’position’. set(gca. Hf_1 = figure(’Units’.35.4]. axis([0. to satisfy the requirements given in Figure P7.’ytick’.0].pha.1.75 1 Figure 7.m). ylabel(’x(n)’.1.’fontsize’.’P7. xlabel(’n’.x.’NumberTitle’.36a’).’fontsize’.’markersize’.’fontsize’. Hs_2 = stem(n. title(’Input Sequence’.3).1).’fontsize’.’fontsize’.y.’filled’).2006 Solutions Manual for DSP using Matlab (2nd Edition) 383 set(Hf_1. set(Hs_1.’off’.’filled’).10). ylabel(’y(n)’.10).’m’. set(Hs_2.1.36b .32: The Time-domain Response in Problem P7.10). title(’Output Sequence’.’markersize’.2). The time-domain response is shown in Figure 7. subplot(2. Hs_1 = stem(n.3).’Name’.’g’.32.10).10). subplot(2. Input Sequence 2 x(n) 1 0 −1 −2 0 10 20 30 40 50 60 70 80 90 100 70 80 90 100 Output Sequence 2 y(n) 1 0 −1 −2 0 10 20 30 40 50 60 n Figure 7. 0.2f’.’off’.25 0.f.%grid.04 Hf_1 = figure(’Units’. m = [2. title(’Amplitude Response’.2 1.37 1 .m(4)].7.’Name’. Achieved Tolerance in the stopband = 0.-0.m(1)].3 and a plot of the amplitude response with grid-lines and axis labeling as shown in Figure P7.75.[f(5).[f(3).2. set(gca.1 0.m(2)].’manual’. close all.f(4)].37 Design of a minimum order linear-phase FIR filter.2 0.[0.f(4)].1].1..’m:’.1.f(6)]. plot([f(7).m(6)]. % Optimum Design M = 45. disp(sprintf(’\n Achieved Tolerance in the stopband = %5.[f(1).37’). to satisfy the requirements given in Figure P7.3. weight = delta(2)*ones(1.f(2)].w. ’paperunits’. set(Hf_1.’NumberTitle’. Hr_min = -min(Hr(126:226)).[f(7).3.’c:’.m.’position’.1.’inches’.ylabel(’H_{r}(\omega)’.[m(7).3 2.[m(1).55.3.0.8 1.0.’y:’..’YTickMode’.’g’.’YTick’.05. %Specifications f = [0.[m(5).f(8)].33.’c:’).’color’.1.m(3)].10) xlabel(’\omega/\pi’.0. Amplitude Response 3. axis([0.sort(YT)).[0. plot(w/pi.[m(2).0. plot([f(5).f).’fontsize’.’g:’).m(8)].2.7 Hr(ω) 2.[1. delta = [0.1.5).f(6)].f(2)]. plot([f(3).’P7.[m(8).’fontsize’.4).7 0.0. using the Parks-McClellan algorithm. YT = m+YT. The amplitude response is shown in Figure 7.L] = hr_type1(h).Hr. YT = (YT(:))’.’m:’).f(8)].33: Amplitude Response Plot in Problem P7.45 ω/π 0.75 Figure 7.-1]*delta.0.3].m(5)].05 −0. hold on.0. YT = [1. m = YT.3.1].’g:’.2.45.0.Hr_min)).’y:’).9 0.’manual’.10).[m(4). [Hr.[m(3). plot([f(1).’paperposition’.weight).25.05 0 0.1]. set(gca.0.0.3.5]).0].’linewidth’.10).Solutions Manual for DSP using Matlab (2nd Edition) 384 2006 P7.6.6.’fontsize’.’XTickMode’.m(7)].[m(6). clc.h = remez(M-1./delta.’XTick’. hold off.55 0.0.a.’inches’.0..3]). + m(3)*(ideal_lp(0. % % Plot of Amplitude Response Hf_1 = figure(’paperunits’.*w_han.2/delta_f. w2 = w(max(find(Hr(I2:I3) <= 0.05.15]. % index into omega array for f(3) band-edge I4 = 500*f(4)+1. h_ideal = m(7)*(ideal_lp(pi.0.90)) + I2-1)/pi. % index into omega array for f(2) band-edge I3 = 500*f(3)+1. % index into omega array for f(4) band-edge I5 = 500*f(5)+1. d2 = 0.0.5]).a.0.0.[0.0.1].6.’off’.0. w6 = w(max(find(Hr(I6:I7) <= 0. % index into omega array for f(8) band-edge (a) Minimum-length linear-phase FIR filter design using a fixed window function. m4 = max(Hr(I7:I8))-m(7).90)) + I4-1)/pi.4. The minimum M was found to be 119 M = 119.’NumberTitle’.0. w3 = w(min(find(Hr(I2:I3) >= 1. % Given specifications f = [0. w5 = w(min(find(Hr(I4:I5) <= 0.05)) + I4-1)/pi.ideal_lp(0.38a’). m2 = max(Hr(I3:I4))-m(3).2006 Solutions Manual for DSP using Matlab (2nd Edition) 385 P7. . set(Hf_1.w.0.475*pi.4.725*pi. % index into omega array for f(1) band-edge I2 = 500*f(2)+1.05. m3 = abs(min(Hr(I5:I6))). to satisfy the given requirements and a plot of the amplitude response with grid-lines as shown in Figure P7.05)) + I2-1)/pi.. w7 = w(min(find(Hr(I6:I7) >= 4.M)).38 The specifications on the amplitude response of an FIR filter are given in Figure P7. w_han = hanning(M)’.15. d4 = 0.ideal_lp(0. w8 = 1. % Computation of Exact tolerances m1 = abs(min(Hr(I1:I2))).M)). h = h_ideal.L] = hr_type1(h).4: % (a) Fixed window design: Stopband Attn <= 39db => Hanning Window delta_f = f(3)-f(2).00)) + I6-1)/pi.5.225*pi.0.0.75.2. M = 6. clc. % Computation of Exact band edges w1 = 0. N = M-1.05)) + I6-1)/pi. close all. % The above value of M is 125.25. % Bandedge Frequencies m = [0.’P7. % index into omega array for f(6) band-edge I7 = 500*f(7)+1.’Name’. M = floor(M/2)*2+1.’paperposition’.M) . % index into omega array for f(5) band-edge I6 = 500*f(6)+1.. w4 = w(max(find(Hr(I4:I5) >= 1.2. % index into omega array for f(7) band-edge I8 = 500*f(8)+1.4. % Nominal (Ideal) band gains d1 = 0. [Hr.3.45.M) .7. d3 = 0.15.1.’inches’. % Band tolerances % Stopband Attenuation As = ceil(-20*log10(d1/(m(7)+d4))) % Band-edge indices I1 = 500*f(1)+1.2. Hr.4f.38a (b) Minimum-length linear-phase FIR filter design using the Kaiser window function to satisfy the given requirements and a plot of the amplitude response with grid-lines as shown in Figure P7.’XTickMode’.3 Hr(w) 4 2. set(gca.’fontsize’.4. %5.f). m1.25 0. w5.0.05 −0. %5. Exact bandedges.beta)’. % The above value of M is 89.10).36*delta_f) + 1).4.5842*(As-21)^0.5). .1. %5.4.-0. M = floor(M/2)*2+1. w4.34. axis([0.1.’YTickMode’. set(gca.Solutions Manual for DSP using Matlab (2nd Edition) 386 2006 plot(w/pi.2. title(’Amplitude Response in Part 1’. w7)).4f. ylabel(’Hr(w)’.75 1 Figure 7. beta = 0. %5.10).95)/(14.’.. %5. Amplitude Response in Part 1 4.4f.45 0.10).0.05.4f..4: % (b) Kaiser Window Design: delta_f = (f(3)-f(2))/2...7.2 0.4f.1 1.07886*(As-21).grid..’fontsize’.’YTick’.’g’.4f. %5.05.4f.’fontsize’. disp(sprintf(’ Exact tolerances: %5.5 ω/π 0. m2. xlabel(’\omega/\pi’. A plot of the amplitude response with grid-lines and axis labeling is shown in Figure 7. w3.N)).9. % Printout of Order. w_kai = kaiser(M.[-0.3]). M = ceil((As .4f. The minimum M was found to be 89 M = 89.’linewidth’.05.4 + 0. disp(sprintf(’ Exact band-edges: %5. w6. and Exact tolerances disp(sprintf(’\n(a) Fixed Window Design:’)).8). set(gca.34: Amplitude Response Plot in Problem P7. m3.4f.1.3]). w2. disp(sprintf(’ Order : %2i’..’XTick’.05 0 0. N = M-1.7 0. %5. m4)).’manual’.4f’.1. %5.’fontsize’.’manual’.9 0. T6. ylabel(’Hr(w)’.1.’fontsize’.85.02.6.’linewidth’.1.9). N = M-1. % The following parameters are obtained by trial and error T1 = 2*0. T5 = 4.10).-0.1. %5.T3.4f.’off’.-0.4: % (c) Frequency Sampling Design: Choose M = 81 % M = 81.4. (c) Minimum-length linear-phase FIR filter design using a frequency-sampling design approach with no more than two optimum samples in the transition bands to satisfy the given requirements and a plot of the amplitude response with grid-lines as shown in Figure P7.N)).4f.0. w6.00)) + I6-1)/pi.9.’paperposition’.2.T4. w4 = w(max(find(Hr(I4:I5) >= 1. m4 = max(Hr(I7:I8))-m(7).8). wl = (2*pi/M)*l. title(’Amplitude Response in Part 2’. % Computation of Exact band edges w1 = 0.0.’Name’.. %5. set(gca.10). + m(3)*(ideal_lp(0.3..’NumberTitle’.2006 Solutions Manual for DSP using Matlab (2nd Edition) 387 h_ideal = m(7)*(ideal_lp(pi.’manual’.10).225*pi.4.15*ones(1.’.1.4f.’P7.15*0.2.. %5. Exact bandedges. w7 = w(min(find(Hr(I6:I7) >= 4.05)) + I4-1)/pi. m3.5). %5. h = h_ideal. w3 = w(min(find(Hr(I2:I3) >= 1.38b’).00.8).6).[0.M) .’manual’. m4)).. w2 = w(max(find(Hr(I2:I3) <= 0. % % Printout of Order. Hrs = [zeros(1.475*pi. m1.2. set(Hf_2.T1. set(gca. %5. %5.T5.05.zeros(1. m3 = abs(min(Hr(I5:I6))).90)) + I4-1)/pi.05.’XTick’.4f’. w5.4f.0.*w_kai. xlabel(’\omega/\pi’.4f.M) .05)) + I2-1)/pi.4f. 2*ones(1. w6 = w(max(find(Hr(I6:I7) <= 0.. disp(sprintf(’ Exact band-edges: %5.[-0.05)) + I6-1)/pi. A plot of the amplitude response with grid-lines and axis labeling is shown in Figure 7. w5 = w(min(find(Hr(I4:I5) <= 0.3]). T3 = 2*0. axis([0. T6 = 4.grid.ideal_lp(0. w7)). disp(sprintf(’ Exact tolerances: %5.4f. T4 = 2*0.7. [Hr. set(gca..4.Hr. w8 = 1.a. %5.. and Exact tolerances disp(sprintf(’\n(b) Kaiser Window Design:’)).T2.’fontsize’.’YTick’.3])..5]).M)).’inches’. T2 = 2*0.1. % % Plot of Amplitude Response Hf_2 = figure(’paperunits’.ideal_lp(0.725*pi. l = 0:M-1.0.4f.90)) + I2-1)/pi. % Computation of Exact tolerances m1 = abs(min(Hr(I1:I2))). w3. m2 = max(Hr(I3:I4))-m(3).’fontsize’. m2.4. w2.9. w4.05.10) .f).’g’.35. disp(sprintf(’ Order : %2i’.’XTickMode’. plot(w/pi.L] = hr_type1(h).’YTickMode’.w.15*0. %5.4f.M)).’fontsize’. alpha = (M-1)/2. ’inches’.*exp(j*angH).5 ω/π 0. angH = [-alpha*(2*pi)/M*k1.05)) + I6-1)/pi.1 1. % % Plot of Amplitude Response Hf_3 = figure(’paperunits’. w2 = w(max(find(Hr(I2:I3) <= 0.3 Hr(w) 4 2.00)) + I6-1)/pi.35: Amplitude Response Plot in Problem P7.2 0. w8 = 1.05 0 0.75 Figure 7. m2 = max(Hr(I3:I4))-m(3). alpha*(2*pi)/M*(M-k2)]. k1 = 0:floor((M-1)/2). k2 = floor((M-1)/2)+1:M-1.6. % % Computation of Exact tolerances m1 = abs(min(Hr(I1:I2))). [Hr.05)) + I2-1)/pi.w.a.7 0.0.05 −0.90)) + I4-1)/pi.90)) + I2-1)/pi. w5 = w(min(find(Hr(I4:I5+1) <= 0.M)). H = Hrs.L] = Hr_Type1(h).45 0. h = real(ifft(H.38b Hrs = [Hrs.5]). w3 = w(min(find(Hr(I2:I3) >= 1.05)) + I4-1)/pi.fliplr(Hrs(2:end))].9 0. m3 = abs(min(Hr(I5:I6))).25 0. 1 . w6 = w(max(find(Hr(I6:I7) <= 0.[0. % % Computation of Exact band edges w1 = 0. w7 = w(min(find(Hr(I6:I7) >= 4. m4 = max(Hr(I7:I8))-m(7).Solutions Manual for DSP using Matlab (2nd Edition) 388 2006 Amplitude Response in Part 2 4. w4 = w(max(find(Hr(I4:I5) >= 1.’paperposition’.3. Hrs(1:41). [Hr.4f. m2.’g’.’P7..4f’. . m4)).4f..38c’).4f. %5.L] = hr_type1(h). M = 65.05 −0.9.m.d1/d2. plot(w/pi.3]).’XTickMode’.’Name’. %5. N = M-1.-0..4.4. set(gca.25 0.Hr.4f.’XTick’.7 0. and Exact tolerances disp(sprintf(’\n(c) Frequency Sampling Design:’)).4f.4f.’linewidth’.05.4f.’NumberTitle’. w2.4f.grid. % % Printout of Order. m1. %5.1. set(gca.9 0.’manual’. ylabel(’Hr(w)’. w3.2.’YTickMode’.a.10). %5. Amplitude Response in Part 3 4. w4.0.5).weights).10). %5.5 ω/π 0. %5.’fontsize’.’.2 0. %5. xlabel(’\omega/\pi’.’off’.’fontsize’.d1/d3. title(’Amplitude Response in Part 3’.45 0.1.wl(1:41)/pi.4f. w7)).’ro’.36: Amplitude Response Plot in Problem P7.05 0 0. %5. axis([0..4: % (d) Equiripple design: The minimum M was found to be 65 % weights = [d1/d1.’YTick’.2006 Solutions Manual for DSP using Matlab (2nd Edition) 389 set(Hf_3..[-0.3 Hr(w) 4 2.1.1. A plot of the amplitude response with grid-lines and axis labeling is shown in Figure 7.38c (d) Minimum-length linear-phase FIR filter design using the Parks-McClellan design approach to satisfy the given requirements and a plot of the amplitude response with grid-lines as shown in Figure P7.’manual’. disp(sprintf(’ Exact tolerances: %5.’fontsize’.05.4. h = remez(M-1.f).10). Exact bandedges.w.N)). disp(sprintf(’ Order : %2i’.. m3. w6. disp(sprintf(’ Exact band-edges: %5.3]).f.75 1 Figure 7.1 1. w5.d1/d4].05.0.36. m4 = max(Hr(I7:I8))-m(7). w2.05)) + I2-1)/pi.1.’Name’.’off’. (e) Comparison of the above four design methods in terms of • the order of the filter • the exact band-edge frequencies • the exact tolerances in each band (a) Fixed Window Design: Order : 118 Exact band-edges: 0.390 Solutions Manual for DSP using Matlab (2nd Edition) 2006 % % Computation of Exact band edges w1 = 0. m3. m2.1. A plot of the amplitude response with grid-lines and axis labeling is shown in Figure 7.7480 Exact tolerances: 0.-0.10). xlabel(’\omega/\pi’. set(gca.38d’). set(gca. %5.10). %5. w7 = w(min(find(Hr(I6:I7) >= 4. and Exact tolerances disp(sprintf(’\n(d) Parks-McClellan Design:’)).4.4f.’inches’.’NumberTitle’.4540. %5. 0.’g’. 0. w2 = w(max(find(Hr(I2:I3) <= 0.5]).6.90)) + I4-1)/pi.9. 0. 0.Hr.0127. plot(w/pi. %5. 0.’XTickMode’.4f.4f.4f’. w5. disp(sprintf(’ Order : %2i’. disp(sprintf(’ Exact tolerances: %5. % % Plot of Amplitude Response Hf_4 = figure(’paperunits’. m3 = abs(min(Hr(I5:I6))). disp(sprintf(’ Exact band-edges: %5.4f.4f..2.0263.3. %5.. axis([0. w3. 0. % % Computation of Exact tolerances m1 = abs(min(Hr(I1:I2))).1. w8 = 1.’P7.0127.2020.’manual’. w6.4f.7000.05.’fontsize’. % % Printout of Order. w3 = w(min(find(Hr(I2:I3) >= 1.5).’linewidth’. Exact bandedges.0.4. %5.05)) + I4-1)/pi.[-0.37.N)).’fontsize’.[0.grid.’YTick’.’paperposition’.’fontsize’..’YTickMode’. w4 = w(max(find(Hr(I4:I5) >= 1.0.0. set(Hf_4. (b) Kaiser Window Design: Order : 88 . w6 = w(max(find(Hr(I6:I7) <= 0.05)) + I6-1)/pi. 0. m4)).4f.4980.4f. %5.05.00)) + I6-1)/pi. w4.4.2460. ylabel(’Hr(w)’.05.3]).f). %5.1. title(’Amplitude Response in Part 4’..’manual’..4f.10)..’XTick’.0262. 0. m1. w7)).’.90)) + I2-1)/pi. w5 = w(min(find(Hr(I4:I5) <= 0. m2 = max(Hr(I3:I4))-m(3).3]). 0706.7 0.0233. 0.7000.2100. 0. 0.05 0 0.0225. 0. 0. 0. 0.0464. 0.4540. (d) Parks-McClellan Design: Order : 64 Exact band-edges: 0.0475.0387.0731.9 0.7480 Exact tolerances: 0.7500 Exact tolerances: 0. 0.37: Amplitude Response Plot in Problem P7.2080. 0.5 ω/π 0. 0.1 1.2500.25 0.1375.2 0. 0. 0.75 Figure 7.0912.7020.2500.7500 Exact tolerances: 0.5000. 0.7000.2460. 0. 0.0262. 0. (c) Frequency Sampling Design: Order : 80 Exact band-edges: 0. 0. 0.2006 Solutions Manual for DSP using Matlab (2nd Edition) 391 Amplitude Response in Part 4 4.05 −0. 0. 0.5020.0460.4500. 0.4540.5000. 0. 1 .0455.45 0.2020. 0.3 Hr(w) 4 2.38d Exact band-edges: 0. .05].1..’position’.39’).95.0].f).05.0.3.8.’NumberTitle’.’YTickMode’.1.[0.8 Figure 7.4. plot(w/pi.’fontsize’. to satisfy the requirements given in Figure P7.75. d2=0.’color’.[0.’fontsize’.weights).0. Amplitude Response 4.4.1.0.3.39 Design of a minimum-order linear-phase FIR filter. set(gca.0.0.’g’.2.01 % Hf_1 = figure(’Units’.5: clc.1 1.3 0.9.5).Solutions Manual for DSP using Matlab (2nd Edition) 392 2006 P7.9 1 0.w.’XTick’. title(’Amplitude Response’.3]).[0.5 and a plot of the amplitude response with grid-lines as shown in Figure P7.’off’.’manual’.0.d4/d4].75 0.f.2f’. axis([0.0..’XTickMode’.’paperposition’.’linewidth’. % Optimum Design h = remez(50.1.05.4. disp(sprintf(’\n Achieved Redsponse in the Band-4 = %5.’inches’. set(Hf_1.1]).3.0.’Name’.5.05.a.Hr.10).[1.L] = hr_type1(h).d4/d2.0.1. ylabel(’H_r(\omega)’.35.0. d4=. xlabel(’\omega/\pi’.6.95.5 0.’inches’.Hr_min)).d4/d3.05. ’paperunits’.’YTick’.5]).9 0 0.’P7. weights = [d4/d1. [Hr.3].6. A plot of the amplitude response with grid-lines and axis labeling is shown in Figure 7.10) set(gca.1 3 2.3. using the Parks-McClellan algorithm.38.05. m = [0.05.35 0. Hr_min = min(Hr(401:501)).10).0.1 4 Hr(ω) 3.4. close all.2.38: Amplitude Response Plot in Problem P7.55.m. d1 = 0.’fontsize’.1].1. % Specifications f = [0.55 ω/π 0. Achieved Redsponse in the Band-4 = 4. grid.9.’manual’.39 1 .0.1. d3=.2.1.3.0. mag.As). axis([0.’XTickLabel’. axis([-1..’g’. % Actual Attn Asd = 41 (a) Plot of the impulse response and the magnitude response in dB of the designed filter: %% 1. (b) Plot the amplitude response of the designed filter: %% 2.h. delta_w = pi/500. xlabel(’\omega/\pi’.’linewidth’.’inches’.db.55. % passband ripple As = 40.’paperposition’.delta2] = db2delta(Rp. set(gca.35*pi. xlabel(’n’. .grd.wp2. m = [0.a.1).0. title(’Impulse Response’.0. Rpd = -min(db((wp1/delta_w)+1:(wp2/delta_w)+1)).’P7.’0.wp1. Amplitude Response plot [Hr.-As-30.w.pha.[0.’0. % Assemble Design Parameters f = [0.6. ylabel(’Decibels’.2*pi.4].40a’).55’..75.1]).0.1.9 using the Parks-McClellan algorithm: clc.’g’. % lower stopband edge wp1 = 0.’fontsize’.55*pi.5).5]).max(h)+0.10).[0.1. ylabel(’h(n)’.35’. %% Specifications: ws1 = 0.w] = freqz_m(h.’position’.10).75*pi.pi]/pi.’fontsize’. Filter Impulse and Log-Magnitude Response Plots Hf_1 = figure(’Units’.[1.1.1]) set(gca.1.[-40.M-1]).[’ 40’.0.’off’.2.f.0.3).6. subplot(2.[0.2). % upper stopband edge Rp = 0.39.35. n= 0:M-1.’Name’.L] = hr_type2(h). Hs_1 = stem(n.’0.’YTickLabel’.[0.75’.ws1. set(Hf_1.2 ’. ’paperunits’. set(Hs_1.8) set(gca.1.’0.0.’fontsize’.25.delta2/delta1.1.4]).0].10) set(gca.ws2.’XTick’.’fontsize’.’filled’).min(h)-0.’ 0 ’]). % stopband attenuation % % Compute Tolerances [delta1.10).0]). % Optimum Design M = 26.’fontsize’.’ 1 ’].’inches’.grid The plots are shown in Figure 7.2006 Solutions Manual for DSP using Matlab (2nd Edition) 393 P7.0].m.’color’. % lower passband edge wp2 = 0.0.’XTick’.’fontsize’.10). title(’Magnitude Response in dB’.’YTick’.2170 Asd = floor(-max(db(1:(ws1/delta_w)+1))).’NumberTitle’.1. weights = [1. h = firpm(M-1. % Response Plots [db. set(gca.10) subplot(2.weights).’fontsize’.M. close all.1]. % upper passband edge ws2 = 0.[’ 0 ’.0.1).. plot(w/pi.’markersize’. % Actual passband ripple Rpd = 0.40 Design of a minimum-length linear-phase bandpass filter of Problem P7.1. 2.’YTick’.10). plot(w/pi.35.6. From Figure 7.1.2 0 −0.10).’0. set(Hf_2.10) set(gca.2.75 1 Figure 7.’0.35 ω/π 0. title(’Amplitude Response’.Solutions Manual for DSP using Matlab (2nd Edition) 394 2006 Impulse Response h(n) 0.’inches’.’XTickLabel’.’linewidth’.0.’fontsize’.1.1-delta1.’P7.’inches’.0].2 0.39: Amplitude Response Plot in Problem P7..0.75’.Hr. .0. grid.’0.’ 1 ’]) set(gca.[’ 0 ’.’0.35’.’color’.0. ’paperunits’.5). ylabel(’Amplitude’.2]). xlabel(’\omega/\pi’.40a Hf_2 = figure(’Units’.40. axis([0.[0.’position’.’g’.3]. Since M = 26 for this design.40.1+delta1]).[1.2 ’.1. L = M/2 − 1 = 12. Thus this is an optimum design.75.9 is M −1 = 43−1 = 42..3]).55 0. set(gca.-0.’fontsize’.[-delta2. Then the extrema are L + 2 or L + 3.[0.2 0 25 n Magnitude Response in dB Decibels 0 40 0 0.’off’.40b’)..1]).1. The plot is shown in Figure 7.’NumberTitle’. the total number of extrema in the error function in the passband and stopbands are 14.6.55.delta2.0. (c) The order of this filter is M −1 = 25 while that of the filter designed in Problem P7. Hence this is a L + 2 = 14 equiripple design.’Name’.’fontsize’.[0.’XTick’.55’.’paperposition’.0. 2 0.75 Figure 7.0144 0.0101 0 0.0101 −0.2006 Solutions Manual for DSP using Matlab (2nd Edition) 395 Amplitude Response Amplitude 1.35 ω/π 0.55 0.9856 0.40b 1 .40: Amplitude Response Plot in Problem P7.
Copyright © 2024 DOKUMEN.SITE Inc.