Proakis ch05
Proakis ch05
201
© 2012 Cengage Learning. All Rights Reserved. This edition is intended for use outside of the U.S. only, with content that may be
different from the U.S. Edition. May not be scanned, copied, duplicated, or posted to a publicly accessible website, in whole or in part.
202 S OLUTIONS M ANUAL FOR E SSENTIALS OF D IGITAL S IGNAL P ROCESSING U SING MATLAB 3 E
1. DFT X(k):
n = 0:100; xn = sinc((n-50)/2).^2; N = length(xn); % given signal x(n)
Xk = dft(xn,N); k = 0:N-1; % DFT of x(n)
mag_Xk = abs(Xk); pha_Xk = angle(Xk)*180/pi; % Mag and Phase of X(k)
zei = find(mag_Xk < 0.00001); % Set phase values to
pha_Xk(zei) = zeros(1,length(zei)); % zero when mag is zero
Hf_1 = figure(’Units’,’normalized’,’position’,[0.1,0.1,0.8,0.8],...
’color’,[0,0,0],’paperunits’,’inches’,’paperposition’,[0,0,6,5]);
set(Hf_1,’NumberTitle’,’off’,’Name’,’P5.2’);
subplot(2,1,1); H_s1 = stem(k,mag_Xk,’filled’); set(H_s1,’markersize’,3);
set(gca,’XTick’,[0:20:N],’fontsize’,8); axis([0,N,0,2.5])
set(gca,’YTick’,[0:0.5:2.5],’fontsize’,8); ylabel(’Magnitude’);
title(’Magnitude plots of DFT and DTFT’,’fontsize’,10); hold on
subplot(2,1,2); H_s2 = stem(k,pha_Xk,’filled’); set(H_s2,’markersize’,3);
set(gca,’XTick’,[0:20:N],’fontsize’,8); axis([0,N,-200,200])
set(gca,’YTick’,[-180;-90;0;90;180],’fontsize’,8);
xlabel(’k’); ylabel(’Degrees’);
title(’Phase plots of DFT and DTFT’,’fontsize’,10); hold on
The stemplotof X(k) is shown in Figure 5.1.
2. DTFT X ejω :
[X,w] = freqz(xn,1,1000,’whole’); % DTFT of xn
mag_X = abs(X); pha_X = angle(X)*180/pi; % mag and phase of DTFT
Dw = (2*pi)/N; % frequency resolution
subplot(2,1,1); plot(w/Dw,mag_X); grid
hold off
subplot(2,1,2); plot(w/Dw,pha_X); grid
hold off
The continuous plot of X ejω is also shown in Figure5.1.
3. Clearly, the DFT in part 1. is the sampled version of X ejω .
© 2012 Cengage Learning. All Rights Reserved. This edition is intended for use outside of the U.S. only, with content that may be
different from the U.S. Edition. May not be scanned, copied, duplicated, or posted to a publicly accessible website, in whole or in part.
S OLUTIONS M ANUAL FOR E SSENTIALS OF D IGITAL S IGNAL P ROCESSING U SING MATLAB 3 E 203
4. 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). We can reconstruct using the complex interpolation formula
−1
N 2πk sin (ωN/2)
X ejω = X (k) φ ω − , where φ (ω) = e−jω(N −1)/2
N N sin (ω/2)
k=0
2
Magnitude
1.5
0.5
0
0 20 40 60 80 100
90
Degrees
−90
−180
0 20 40 60 80 100
k
© 2012 Cengage Learning. All Rights Reserved. This edition is intended for use outside of the U.S. only, with content that may be
different from the U.S. Edition. May not be scanned, copied, duplicated, or posted to a publicly accessible website, in whole or in part.
204 S OLUTIONS M ANUAL FOR E SSENTIALS OF D IGITAL S IGNAL P ROCESSING U SING MATLAB 3 E
P5.3 The DTFT X(ejω ) of the following finite-length sequence using DFT as a computation tool
−0.9|n|
2e , −5 ≤ n ≤ 5;
x(n) =
0, otherwise.
M ATLAB script:
2
Amplitude
−1
−2
−3
−4
−1 −0.8 −0.6 −0.4 −0.2 0 0.2 0.4 0.6 0.8 1
ω/π
© 2012 Cengage Learning. All Rights Reserved. This edition is intended for use outside of the U.S. only, with content that may be
different from the U.S. Edition. May not be scanned, copied, duplicated, or posted to a publicly accessible website, in whole or in part.
S OLUTIONS M ANUAL FOR E SSENTIALS OF D IGITAL S IGNAL P ROCESSING U SING MATLAB 3 E 205
P5.4 Plot of the DTFT magnitude and angle of each of the following sequences using the DFT as a computation
tool.
1. x1 (n) = (0.6)|n| [u(n + 10) − u(n − 10)]. M ATLAB script:
n1 = [-10:10]; x1 = (0.6).^abs(n1); N1 = length(n1); N = 200; % Length of DFT
x1 = [x1(11:end), zeros(1,N-N1), x1(1:10)]; % Assemble x1
[X1] = fft(x1,N); w = (0:N/2)*2*pi/N;
mag_X1 = abs(X1(1:N/2+1)); pha_X1 = angle(X1(1:N/2+1))*180/pi;
Hf_1 = figure(’Units’,’inches’,’position’,[1,1,6,4],...
’color’,[0,0,0],’paperunits’,’inches’,’paperposition’,[0,0,6,4]);
set(Hf_1,’NumberTitle’,’off’,’Name’,’P5.4.1’);
subplot(2,1,1); plot(w/pi,mag_X1,’g’,’linewidth’,1); axis([0,1,0,11]);
title(’Magnitude of DTFT X_1(e^{j\omega})’); ylabel(’Magnitude’);
subplot(2,1,2); plot(w/pi,pha_X1,’g’,’linewidth’,1); axis([0,1,-200,200]);
title(’Angle of DTFT X_1(e^{j\omega})’); ylabel(’Degrees’); xlabel(’\omega/\pi’);
print -deps2 ../EPSFILES/P0504a
The plot of the DTFT X1 (ejω ) is shown in Figure 5.3.
4
Magnitude
0
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
100
Degrees
−100
−200
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
ω/π
© 2012 Cengage Learning. All Rights Reserved. This edition is intended for use outside of the U.S. only, with content that may be
different from the U.S. Edition. May not be scanned, copied, duplicated, or posted to a publicly accessible website, in whole or in part.
206 S OLUTIONS M ANUAL FOR E SSENTIALS OF D IGITAL S IGNAL P ROCESSING U SING MATLAB 3 E
40
20
0
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
100
Degrees
−100
−200
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
ω/π
© 2012 Cengage Learning. All Rights Reserved. This edition is intended for use outside of the U.S. only, with content that may be
different from the U.S. Edition. May not be scanned, copied, duplicated, or posted to a publicly accessible website, in whole or in part.
S OLUTIONS M ANUAL FOR E SSENTIALS OF D IGITAL S IGNAL P ROCESSING U SING MATLAB 3 E 207
40
20
0
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
100
Degrees
−100
−200
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
ω/π
© 2012 Cengage Learning. All Rights Reserved. This edition is intended for use outside of the U.S. only, with content that may be
different from the U.S. Edition. May not be scanned, copied, duplicated, or posted to a publicly accessible website, in whole or in part.
208 S OLUTIONS M ANUAL FOR E SSENTIALS OF D IGITAL S IGNAL P ROCESSING U SING MATLAB 3 E
15
Magnitude
10
0
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
100
Degrees
−100
−200
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
ω/π
© 2012 Cengage Learning. All Rights Reserved. This edition is intended for use outside of the U.S. only, with content that may be
different from the U.S. Edition. May not be scanned, copied, duplicated, or posted to a publicly accessible website, in whole or in part.
S OLUTIONS M ANUAL FOR E SSENTIALS OF D IGITAL S IGNAL P ROCESSING U SING MATLAB 3 E 209
15
Magnitude
10
0
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
100
Degrees
−100
−200
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
ω/π
© 2012 Cengage Learning. All Rights Reserved. This edition is intended for use outside of the U.S. only, with content that may be
different from the U.S. Edition. May not be scanned, copied, duplicated, or posted to a publicly accessible website, in whole or in part.
210 S OLUTIONS M ANUAL FOR E SSENTIALS OF D IGITAL S IGNAL P ROCESSING U SING MATLAB 3 E
P5.5 Let H(ejω ) be the frequency response of a real, causal impulse response h(n).
5 k
1. It is known that Re H ejω = k=0 (0.9) cos ωk. Consider
∞ ∞ ∞
jω
−jωk
Re H e = Re h(k)e = h(k) Re e−jωk = h(k) cos ωk
k=0 k=0 k=0
M ATLAB verification:
n = 0:5; h = (0.9).^n; N1 = length(h); N = 100; h = [h,zeros(1,N-N1)];
H = dft(h,N); Hr = real(H);
k = [0:5]; w = linspace(0,2*pi,N+1);
Hr_check = (0.9.^k)*cos(k’*w(1:end-1));
error = max(abs(Hr-Hr_check))
error =
4.0856e-014
5
π
2. It is known that Im H ejω = =0 2 sin ω and −π H ejω dω = 0. From the second condition
π
H ejω dω = h (0) = 0
−π
Consider
∞ ∞ ∞
jω
Im H e = Im h()e−jω = h () Im e−jω = − h () sin ω
=0 =0 =0
M ATLAB verification:
n = 0:5; h = -2*n; N1 = length(h); N = 100; h = [h,zeros(1,N-N1)];
H = dft(h,N); Hi = imag(H);
l = [0:5]; w = linspace(0,2*pi,N+1);
Hi_check = 2*l*sin(l’*w(1:end-1));
error = max(abs(Hi-Hi_check))
error =
3.8014e-013
© 2012 Cengage Learning. All Rights Reserved. This edition is intended for use outside of the U.S. only, with content that may be
different from the U.S. Edition. May not be scanned, copied, duplicated, or posted to a publicly accessible website, in whole or in part.
S OLUTIONS M ANUAL FOR E SSENTIALS OF D IGITAL S IGNAL P ROCESSING U SING MATLAB 3 E 211
P5.6 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.
N
−1 N
−1
1. The N -point DFT of x (n): X (k) = x (m) WNmk . The N -point DFT of X (k): y (n) = X (k) WNkn .
m=0 k=0
Hence,
−1
N −1 −1 −1
N
N
N
y (n) = x (m) WNmk WNkn = x (m) WNmk WNkn , 0 ≤ n ≤ N − 1
k=0 m=0 m=0 k=0
N −1
N −1
N −1 ∞
(m+n)k
= x (m) WN = x (m) N δ (m + n − rN ) , 0 ≤ n ≤ N − 1
m=0 k=0 m=0 r=−∞
∞
= N x (−n + rN ) = N x ((−n))N , 0 ≤ n ≤ N − 1
r=−∞
This means that y (n) is a “circularly folded and amplified (by N )” version of x (n). Continuing further,
if we take two more DFTs of x (n) then
Therefore, 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 ). This approach can be used to
verify a DFT function.
2. M ATLAB function for circular folding:
function x2 = circfold(x1,N)
% Circular folding with respect to N
% ----------------------------------
% function x2 = circfold(x1,N)
% x2(n) = x1((-n) mod N)
%
x2 = real(dft(dft(x1,N),N))/N;
3. M ATLAB verification:
x = [1,3,5,7,9,-7,-5,-3,-1], N = length(x);
x =
1 3 5 7 9 -7 -5 -3 -1
Y = circfold(x,N)
Y =
1.000 -1.000 -3.000 -5.000 -7.000 9.000 7.000 5.000 3.000
© 2012 Cengage Learning. All Rights Reserved. This edition is intended for use outside of the U.S. only, with content that may be
different from the U.S. Edition. May not be scanned, copied, duplicated, or posted to a publicly accessible website, in whole or in part.
212 S OLUTIONS M ANUAL FOR E SSENTIALS OF D IGITAL S IGNAL P ROCESSING U SING MATLAB 3 E
= X̃(−k) = X̃(N − k)
2. Let x̃(n) = {2, 4, 6, 1, 3, 5}PERIODIC with N = 6.
↑
(a) Sketch of ỹ(n) for 0 ≤ n ≤ 5:
One period of the periodic sequence xtilde(n)
7
6
5
Amplitude
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,N)
X_tilde =
Columns 1 through 4
21.0000 1.0000 - 1.7321i -6.0000 + 3.4641i 1.0000 - 0.0000i
Columns 5 through 6
-6.0000 - 3.4641i 1.0000 + 1.7321i
(c) Computation of Ỹ (k) for 0 ≤ k ≤ 5:
y_tilde = [x_tilde(1),fliplr(x_tilde(2:end))];
Y_tilde = dft(y_tilde,N)
Y_tilde =
Columns 1 through 4
21.0000 1.0000 + 1.7321i -6.0000 - 3.4641i 1.0000 + 0.0000i
Columns 5 through 6
-6.0000 + 3.4641i 1.0000 - 1.7321i
(d) M ATLAB verification:
W_tilde = [X_tilde(1),fliplr(X_tilde(2:end))];
error = max(abs(Y_tilde - W_tilde))
error =
2.5434e-014
© 2012 Cengage Learning. All Rights Reserved. This edition is intended for use outside of the U.S. only, with content that may be
different from the U.S. Edition. May not be scanned, copied, duplicated, or posted to a publicly accessible website, in whole or in part.
S OLUTIONS M ANUAL FOR E SSENTIALS OF D IGITAL S IGNAL P ROCESSING U SING MATLAB 3 E 213
P5.8 Determine the periodic sequences given the following periodic DFS coefficients. First use the IDFS defi-
nition and then verify your answers using M ATLAB .
1. X̃1 (k) = {4, 3j, −3j}, N = 3
© 2012 Cengage Learning. All Rights Reserved. This edition is intended for use outside of the U.S. only, with content that may be
different from the U.S. Edition. May not be scanned, copied, duplicated, or posted to a publicly accessible website, in whole or in part.
214 S OLUTIONS M ANUAL FOR E SSENTIALS OF D IGITAL S IGNAL P ROCESSING U SING MATLAB 3 E
P5.9 Let x̃1 (n) be periodic with fundamental period N = 40 where one period is given by
5 sin(0.1πn), 0 ≤ n ≤ 19
x̃1 (n) =
0, 20 ≤ n ≤ 39
and let x̃2 (n) be periodic with fundamental period N = 80, where one period is given by
5 sin(0.1πn), 0 ≤ n ≤ 19
x̃2 (n) =
0, 20 ≤ n ≤ 79
These two periodic sequences differ in their periodicity but otherwise have the same non-zero samples.
1. Computation of X̃1 (k) using M ATLAB :
n1 = [0:39]; xtilde1 = [5*sin(0.1*pi*[0:19]),zeros(1,20)]; N1 = length(n1);
[Xtilde1] = dft(xtilde1,N1); k1 = n1;
mag_Xtilde1 = abs(Xtilde1); pha_Xtilde1 = angle(Xtilde1)*180/pi;
zei = find(mag_Xtilde1 < 1000*eps);
pha_Xtilde1(zei) = zeros(1,length(zei));
Hf_1 = figure(’Units’,’normalized’,’position’,[0.1,0.1,0.8,0.8],...
’color’,[0,0,0],’paperunits’,’inches’,’paperposition’,[0,0,6,5]);
set(Hf_1,’NumberTitle’,’off’,’Name’,’P5.9.1’);
subplot(3,1,1); H_s1 = stem(n1,xtilde1,’filled’); set(H_s1,’markersize’,3);
axis([-1,N1,-6,6]);
title(’One period of the periodic sequence xtilde_1(n)’,’fontsize’,10);
ntick = [n1(1):2:n1(N1),N1]’; ylabel(’Amplitude’);
set(gca,’XTickMode’,’manual’,’XTick’,ntick,’FontSize’,8);
subplot(3,1,2); H_s2 = stem(k1,mag_Xtilde1,’filled’); set(H_s2,’markersize’,3);
axis([-1,N1,0,max(mag_Xtilde1)+10]);
title(’Magnitude of Xtilde_1(k)’,’fontsize’,10); ylabel(’Magnitude’);
ktick = [k1(1):2:k1(N1),N1]’;
set(gca,’XTickMode’,’manual’,’XTick’,ktick,’FontSize’,8)
subplot(3,1,3); H_s3 = stem(k1,pha_Xtilde1,’filled’); set(H_s3,’markersize’,3);
title(’Phase of Xtilde_1(k)’,’fontsize’,10); xlabel(’k’); ylabel(’Degrees’);
ktick = [k1(1):2:k1(N1),N1]’; axis([-1,N1,-200,200]);
set(gca,’XTickMode’,’manual’,’XTick’,ktick,’FontSize’,8);
set(gca,’YTickMode’,’manual’,’YTick’,[-180;-90;0;90;180]);
Plots of x̃1 (n) and X̃1 (k) are shown in Figure 5.8.
2. Computation of X̃2 (k) using M ATLAB :
n2 = [0:79]; xtilde2 = [xtilde1, zeros(1,40)]; N2 = length(n2);
[Xtilde2] = dft(xtilde2,N2); k2 = n2;
mag_Xtilde2 = abs(Xtilde2); pha_Xtilde2 = angle(Xtilde2)*180/pi;
zei = find(mag_Xtilde2 < 1000*eps);
pha_Xtilde2(zei) = zeros(1,length(zei));
Hf_2 = figure(’Units’,’normalized’,’position’,[0.1,0.1,0.8,0.8],...
’color’,[0,0,0],’paperunits’,’inches’,’paperposition’,[0,0,6,5]);
set(Hf_2,’NumberTitle’,’off’,’Name’,’P5.9.2’);
subplot(3,1,1); H_s1 = stem(n2,xtilde2,’filled’); set(H_s1,’markersize’,3);
© 2012 Cengage Learning. All Rights Reserved. This edition is intended for use outside of the U.S. only, with content that may be
different from the U.S. Edition. May not be scanned, copied, duplicated, or posted to a publicly accessible website, in whole or in part.
S OLUTIONS M ANUAL FOR E SSENTIALS OF D IGITAL S IGNAL P ROCESSING U SING MATLAB 3 E 215
Amplitude
0
−5
0 2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 40
Magnitude of Xtilde1(k)
60
Magnitude
40
20
0
0 2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 40
Phase of Xtilde1(k)
180
90
Degrees
0
−90
−180
0 2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 40
k
Figure 5.8: Plots of x̃1 (n) and X̃1 (k) in Problem 5.9.1
© 2012 Cengage Learning. All Rights Reserved. This edition is intended for use outside of the U.S. only, with content that may be
different from the U.S. Edition. May not be scanned, copied, duplicated, or posted to a publicly accessible website, in whole or in part.
216 S OLUTIONS M ANUAL FOR E SSENTIALS OF D IGITAL S IGNAL P ROCESSING U SING MATLAB 3 E
3. Changing the period from N = 40 to N = 80 resulted in a lower frequency sampling interval (higher
frequency resolution) ω1 , i.e., in (5) ω1 = π/20 and in (5) ω2 = π/40. Hence there are more terms in the
DFS expansion of x̃2 (n). The shape of the DTFT begins to fill in with N = 80.
−5
0 5 10 15 20 25 30 35 40 45 50 55 60 65 70 75 80
Magnitude of Xtilde2(k)
60
40
|Xtilde2|
20
0
0 5 10 15 20 25 30 35 40 45 50 55 60 65 70 75 80
Phase of Xtilde2(k)
180
90
Degrees
−90
−180
0 5 10 15 20 25 30 35 40 45 50 55 60 65 70 75 80
k
Figure 5.9: Plots of Magnitude and Phase of X̃2 (k) in Problem 5.9.2
© 2012 Cengage Learning. All Rights Reserved. This edition is intended for use outside of the U.S. only, with content that may be
different from the U.S. Edition. May not be scanned, copied, duplicated, or posted to a publicly accessible website, in whole or in part.
S OLUTIONS M ANUAL FOR E SSENTIALS OF D IGITAL S IGNAL P ROCESSING U SING MATLAB 3 E 217
P5.10 Consider the periodic sequence x̃1 (n) given in Problem 5.9. Let x̃2 (n) be periodic with fundamental
period N = 40, where one period is given by
x̃1 (n), 0 ≤ n ≤ 19
x̃2 (n) =
−x̃1 (n − 20), 20 ≤ n ≤ 39
© 2012 Cengage Learning. All Rights Reserved. This edition is intended for use outside of the U.S. only, with content that may be
different from the U.S. Edition. May not be scanned, copied, duplicated, or posted to a publicly accessible website, in whole or in part.
218 S OLUTIONS M ANUAL FOR E SSENTIALS OF D IGITAL S IGNAL P ROCESSING U SING MATLAB 3 E
−5
0 5 10 15 20 25 30 35 40
Magnitude of Xtilde2(k)
100
Magnitude
50
0
0 5 10 15 20 25 30 35 40
Phase of Xtilde2(k)
180
90
Degrees
0
−90
−180
0 5 10 15 20 25 30 35 40
k
Figure 5.10: Plots of Magnitude and Phase of X̃2 (k) in Problem 5.10.2
© 2012 Cengage Learning. All Rights Reserved. This edition is intended for use outside of the U.S. only, with content that may be
different from the U.S. Edition. May not be scanned, copied, duplicated, or posted to a publicly accessible website, in whole or in part.
S OLUTIONS M ANUAL FOR E SSENTIALS OF D IGITAL S IGNAL P ROCESSING U SING MATLAB 3 E 219
P5.11 Consider the periodic sequence x̃1 (n) given in Problem 5.9. Let x̃3 (n) be periodic with period 80, ob-
tained by concatenating two periods of x̃1 (n), i.e.,
Clearly, x̃3 (n) is different from x̃2 (n) of Problem 5.9 even though both of them are periodic with period
80.
1. Computation and plot of the DFS X̃3 (k) using M ATLAB :
n1 = [0:39]; xtilde1 = [5*sin(0.1*pi*[0:19]),zeros(1,20)];
n3 = [0:79]; xtilde3 = [xtilde1, xtilde1]; N3 = length(n3);
[Xtilde3] = dft(xtilde3,N3); k3 = n3;
mag_Xtilde3 = abs(Xtilde3); pha_Xtilde3 = angle(Xtilde3)*180/pi;
zei = find(mag_Xtilde3 < 0.00001);
pha_Xtilde3(zei) = zeros(1,length(zei));
Hf_1 = figure(’Units’,’normalized’,’position’,[0.1,0.1,0.8,0.8],...
’color’,[0,0,0],’paperunits’,’inches’,’paperposition’,[0,0,6,5]);
set(Hf_1,’NumberTitle’,’off’,’Name’,’P5.11.1’);
subplot(3,1,1); H_s1 = stem(n3,xtilde3,’filled’); set(H_s1,’markersize’,3);
title(’One period of the periodic sequence xtilde_3(n)’,’fontsize’,10);
ylabel(’Amplitude’); ntick = [n3(1):5:n3(N3),N3]’;axis([-1,N3,-6,6]);
set(gca,’XTickMode’,’manual’,’XTick’,ntick,’fontsize’,8)
subplot(3,1,2); H_s2 = stem(k3,mag_Xtilde3,’filled’); set(H_s2,’markersize’,3);
axis([-1,N3,min(mag_Xtilde3),max(mag_Xtilde3)]);
title(’Magnitude of Xtilde_3(k)’,’fontsize’,10); ylabel(’Magnitude’)
ktick = [k3(1):5:k3(N3),N3]’; set(gca,’XTickMode’,’manual’,’XTick’,ktick)
subplot(3,1,3); H_s3 = stem(k3,pha_Xtilde3,’filled’); set(H_s3,’markersize’,3);
title(’Phase of Xtilde3(k)’,’fontsize’,10); xlabel(’k’); ylabel(’Degrees’);
ktick = [k3(1):5:k3(N3),N3]’;axis([-1,N3,-180,180]);
set(gca,’XTickMode’,’manual’,’XTick’,ktick)
set(gca,’YTickMode’,’manual’,’YTick’,[-180;-90;0;90;180])
Plots of x̃3 (n) and X̃3 (k) are shown in Figure 5.11.
© 2012 Cengage Learning. All Rights Reserved. This edition is intended for use outside of the U.S. only, with content that may be
different from the U.S. Edition. May not be scanned, copied, duplicated, or posted to a publicly accessible website, in whole or in part.
220 S OLUTIONS M ANUAL FOR E SSENTIALS OF D IGITAL S IGNAL P ROCESSING U SING MATLAB 3 E
−5
0 5 10 15 20 25 30 35 40 45 50 55 60 65 70 75 80
Magnitude of Xtilde3(k)
100
Magnitude
50
0
0 5 10 15 20 25 30 35 40 45 50 55 60 65 70 75 80
Phase of Xtilde3(k)
180
90
Degrees
−90
−180
0 5 10 15 20 25 30 35 40 45 50 55 60 65 70 75 80
k
Figure 5.11: Plots of x̃3 (n) and X̃3 (k) in Problem 5.11.1
2. Plots of X̃3 (k) have one zero between every sample of X̃1 (k). (In general, for phase plots, we do get non-
zero phase values when the magnitudes are zero. Clearly these phase values have no meaning and should
be ignored. This happens because of a particular algorithm used by M ATLAB. We avoided this problem
by using the find function.) This makes sense because sequences x̃1 (n) and x̃3 (n), when viewed over
−∞ < n < ∞ interval, look exactly same. The effect of periodicity doubling is in the doubling of
magnitude of each sample.
1. We can now generalize this argument. If
⎧ ⎫
⎨ ⎬
x̃M (n) = x̃1 (n) , x̃1 (n) , . . . , x̃1 (n)
⎩ ⎭
M times PERIODIC
then there will be (M − 1) zeros between samples of X̃M (k). The magnitudes of non-zero samples of
X̃M (k) will be M times the magnitudes of the samples of X̃1 (k), i.e.,
© 2012 Cengage Learning. All Rights Reserved. This edition is intended for use outside of the U.S. only, with content that may be
different from the U.S. Edition. May not be scanned, copied, duplicated, or posted to a publicly accessible website, in whole or in part.
S OLUTIONS M ANUAL FOR E SSENTIALS OF D IGITAL S IGNAL P ROCESSING U SING MATLAB 3 E 221
1. Let
10-point
y1 (n) = IDFS X(ej0 ), X(ej2π/10 ), X(ej4π/10 ), . . . , X(ej18π/10 )
which is a 10-point IDFS of ten samples of X ejω on the unit circle. Thus
∞
y1 (n) = x(n − 10r) = {1 + 11 + · · · + 41 + 50 + 40 + · · · + 10,
r=−∞
2 + 12 + · · · + 42 + 49 + · · · + 9, · · · }periodic
= {255, 255, . . . , 255}periodic
M ATLAB verification:
n = 0:99; x = [n(1:50)+1,100-n(51:100)];
N1 = 10; k1 = 0:N1-1; w1 = 2*pi*k1/N1;
Y1 = dtft(x,n,w1); y1 = real(idfs(Y1,N1));
See the stem plot of y1 (n) in Figure 5.12.
2. Let
200-point
y2 (n) = IDFS X(ej0 ), X(ej2π/200 ), X(ej4π/200 ), . . . , X(ej398π/200 )
which is a 200-point IDFS of 200 samples of X ejω on the unit circle. Thus
x(n), 0 ≤ n ≤ 49;
y2 (n) =
0, 50 ≤ n ≤ 100. periodic
M ATLAB verification:
n = 0:99; x = [n(1:50)+1,100-n(51:100)];
N2 = 200; k2 = 0:N2-1; w2 = 2*pi*k2/N2;
Y2 = dtft(x,n,w2); y2 = real(idfs(Y2,N2));
See the stem plot of y1 (n) in Figure 5.12.
3. The sequence y1 (n) is a 10-point aliasing version on x(n) while y2 (n) is a zero-padded version of x(n).
© 2012 Cengage Learning. All Rights Reserved. This edition is intended for use outside of the U.S. only, with content that may be
different from the U.S. Edition. May not be scanned, copied, duplicated, or posted to a publicly accessible website, in whole or in part.
222 S OLUTIONS M ANUAL FOR E SSENTIALS OF D IGITAL S IGNAL P ROCESSING U SING MATLAB 3 E
40
Amplitude
20
0
0 10 20 30 40 50 60 70 80 90 100
200
100
0
0 1 2 3 4 5 6 7 8 9 10 11
50
40
Amplitude
30
20
10
0
−1 49 99 149 199
n
© 2012 Cengage Learning. All Rights Reserved. This edition is intended for use outside of the U.S. only, with content that may be
different from the U.S. Edition. May not be scanned, copied, duplicated, or posted to a publicly accessible website, in whole or in part.
S OLUTIONS M ANUAL FOR E SSENTIALS OF D IGITAL S IGNAL P ROCESSING U SING MATLAB 3 E 223
P5.13 The first six values of the 10-point DFT of a real-valued sequence x(n) are given by
© 2012 Cengage Learning. All Rights Reserved. This edition is intended for use outside of the U.S. only, with content that may be
different from the U.S. Edition. May not be scanned, copied, duplicated, or posted to a publicly accessible website, in whole or in part.
224 S OLUTIONS M ANUAL FOR E SSENTIALS OF D IGITAL S IGNAL P ROCESSING U SING MATLAB 3 E
© 2012 Cengage Learning. All Rights Reserved. This edition is intended for use outside of the U.S. only, with content that may be
different from the U.S. Edition. May not be scanned, copied, duplicated, or posted to a publicly accessible website, in whole or in part.
S OLUTIONS M ANUAL FOR E SSENTIALS OF D IGITAL S IGNAL P ROCESSING U SING MATLAB 3 E 225
© 2012 Cengage Learning. All Rights Reserved. This edition is intended for use outside of the U.S. only, with content that may be
different from the U.S. Edition. May not be scanned, copied, duplicated, or posted to a publicly accessible website, in whole or in part.
226 S OLUTIONS M ANUAL FOR E SSENTIALS OF D IGITAL S IGNAL P ROCESSING U SING MATLAB 3 E
© 2012 Cengage Learning. All Rights Reserved. This edition is intended for use outside of the U.S. only, with content that may be
different from the U.S. Edition. May not be scanned, copied, duplicated, or posted to a publicly accessible website, in whole or in part.
S OLUTIONS M ANUAL FOR E SSENTIALS OF D IGITAL S IGNAL P ROCESSING U SING MATLAB 3 E 227
© 2012 Cengage Learning. All Rights Reserved. This edition is intended for use outside of the U.S. only, with content that may be
different from the U.S. Edition. May not be scanned, copied, duplicated, or posted to a publicly accessible website, in whole or in part.
228 S OLUTIONS M ANUAL FOR E SSENTIALS OF D IGITAL S IGNAL P ROCESSING U SING MATLAB 3 E
P5.14 Complex-valued N -point sequence x(n) can be decomposed into N -point circular-conjugate-
symmetric and circular-conjugate-antisymmetric sequences using the following relations
1
xccs (n)= [x(n) + x∗ ((−n))N ]
2
1
xcca (n)= [x(n) − x∗ ((−n))N ]
2
If XR (k) and XI (k) are the real and imaginary parts of the N -point DFT of x(n), then
DFT [xccs (n)] = XR (k) and DFT [xcca (n)] = jXI (k)
1. Using the DFT properties of conjugation and circular folding, we obtain
1
DFT [xccs (n)] = {DFT [x(n)] + DFT [x∗ ((−n))N ]}
2
1
= X(k) + X̂ ∗ ((−k))N , where X̂(k) = DFT [x((−n))N ]
2
1
= {X(k) + X ∗ (k)} = Re [X(k)] = XR (k)
2
similarly, we can show that
DFT [xcca (n)] = j Im [X(k)] = jXI (k)
2. The modified circevod function:
function [xccs, xcca] = circevod(x)
% Complex-valued signal decomposition into circular-even and circular-odd parts
% ----------------------------------------------------------------------------
-
% [xccs, xcca] = circecod(x)
%
N = length(x); n = 0:(N-1);
xccs = 0.5*(x + conj(x(mod(-n,N)+1)));
xcca = 0.5*(x - conj(x(mod(-n,N)+1)));
3. Let X(k) = [3 cos(0.2πk)+j4 sin(0.1πk)][u(k)−u(k−20)] be a 20-point DFT. M ATLAB verification:
N = 20; k = 0:N-1; X = 3*cos(0.2*pi*k) + j*sin(0.1*pi*k);
n = 0:N-1; x = idft(X,N); [xccs, xcca] = circevod(x);
Xccs = dft(xccs,N); Xcca = dft(xcca,N);
Hf_1 = figure(’Units’,’inches’,’position’,[1,1,6,4],...
’paperunits’,’inches’,’paperposition’,[0,0,6,4],’color’,[0,0,0]);
set(Hf_1,’NumberTitle’,’off’,’Name’,’P5.14.3’);
subplot(2,2,1); H_s1 = stem(n,real(X),’filled’); set(H_s1,’markersize’,3);
title(’X_R(k)’); ylabel(’Amplitude’); axis([-0.5,20.5,-4,4]);
subplot(2,2,3); H_s2 = stem(n,real(Xccs),’filled’); set(H_s2,’markersize’,3);
title(’X_{ccs}(k)’); ylabel(’Amplitude’); xlabel(’k’); axis([-0.5,20.5,-4,4]);
subplot(2,2,2); H_s3 = stem(n,imag(X),’filled’); set(H_s3,’markersize’,3);
title(’X_I(k)’); ylabel(’Amplitude’); axis([-0.5,20.5,-1.1,1.1]);
subplot(2,2,4); H_s4 = stem(n,imag(Xcca),’filled’); set(H_s4,’markersize’,3);
title(’X_{cca}(k)’); ylabel(’Amplitude’); xlabel(’k’); axis([-0.5,20.5,-1.1,1.1]);
© 2012 Cengage Learning. All Rights Reserved. This edition is intended for use outside of the U.S. only, with content that may be
different from the U.S. Edition. May not be scanned, copied, duplicated, or posted to a publicly accessible website, in whole or in part.
S OLUTIONS M ANUAL FOR E SSENTIALS OF D IGITAL S IGNAL P ROCESSING U SING MATLAB 3 E 229
XR(k) XI(k)
4
1
2 0.5
Amplitude
Amplitude
0 0
−2 −0.5
−1
−4
0 5 10 15 20 0 5 10 15 20
Xccs(k) Xcca(k)
4
1
2 0.5
Amplitude
0 Amplitude 0
−2 −0.5
−1
−4
0 5 10 15 20 0 5 10 15 20
k k
© 2012 Cengage Learning. All Rights Reserved. This edition is intended for use outside of the U.S. only, with content that may be
different from the U.S. Edition. May not be scanned, copied, duplicated, or posted to a publicly accessible website, in whole or in part.
230 S OLUTIONS M ANUAL FOR E SSENTIALS OF D IGITAL S IGNAL P ROCESSING U SING MATLAB 3 E
P5.15 (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) + jxI (n)
where xR (n) and xI (n) are the real and imaginary parts of x(n), then
DFT [xR (n)] = Xccs (k) and DFT [jxI (n)] = Xcca (k)
where Xccs (k) and Xcca (k) are the circular-even and circular-odd components of X(k) as defined in
Problem 5.14.
1. Analytical proof: Consider
1
XR (k)= DFT [xR (n)] = {DFT [x(n)] + DFT [x∗ (n)]}
2
1
= {X(k) + X ∗ ((−k))N } =Xccs
2
Similarly
⎫
1 ⎪
jXI (k) = DFT [jxI (n)] = {DFT [x(n)] − DFT [x (n)]} ⎬
∗
Xcca (k)
2 ⇒ XI (k) = = −jXcca (k)
1 ⎪ j
= {X(k) − X ∗ ((−k))N } =Xcca ⎭
2
2. This property can be used to compute the DFTs of two real-valued N -point sequences using one N -
point DFT operation. Specifically, let x1 (n) and x2 (n) be two N -point sequences. Then we can form
a complex-valued sequence
x(n) = x1 (n) + jx2 (n)
and use the above property. M ATLAB function real2dft:
function [X1,X2] = real2dft(x1,x2,N)
% DFTs of two real sequences
% [X1,X2] = real2dft(x1,x2,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); x1 = [x1 zeros(1,N-N1)];
N2 = length(x2); x2 = [x2 zeros(1,N-N2)];
x = x1 + j*x2;
X = dft(x,N);
[X1, X2] = circevod(X); X2 = X2/j;
© 2012 Cengage Learning. All Rights Reserved. This edition is intended for use outside of the U.S. only, with content that may be
different from the U.S. Edition. May not be scanned, copied, duplicated, or posted to a publicly accessible website, in whole or in part.
S OLUTIONS M ANUAL FOR E SSENTIALS OF D IGITAL S IGNAL P ROCESSING U SING MATLAB 3 E 231
We will also need the circevod function for complex sequences (see Problem P5.14). This can be
obtained from the one given in the text by two simple changes.
function [xccs, xcca] = circevod(x)
% Complex signal decomposition into circular-even and circular-odd parts
% ----------------------------------------------------------------------
% [xccs, xcca] = circecod(x)
%
N = length(x); n = 0:(N-1);
xccs = 0.5*(x + conj(x(mod(-n,N)+1)));
xcca = 0.5*(x - conj(x(mod(-n,N)+1)));
3. Compute and plot the DFTs of the following two sequences using the above function
M ATLAB verification:
N = 40; n = 0:N-1; x1 = cos(0.1*pi*n); x2 = sin(0.2*pi*n);
[X1,X2] = real2dft(x1,x2,N);
X11 = dft(x1,N); X21 = dft(x2,N);
difference = max(abs(X1-X11))
difference = max(abs(X2-X21))
difference =
3.6876e-013
difference =
3.6564e-013
© 2012 Cengage Learning. All Rights Reserved. This edition is intended for use outside of the U.S. only, with content that may be
different from the U.S. Edition. May not be scanned, copied, duplicated, or posted to a publicly accessible website, in whole or in part.
232 S OLUTIONS M ANUAL FOR E SSENTIALS OF D IGITAL S IGNAL P ROCESSING U SING MATLAB 3 E
P5.16 Circular shifting: The M ATLAB routine cirshftf.m to implement circular shift is written using the
frequency-domain property
y(n)=x((n − m))N = IDFT X(k)WNmk
This routine will be used in the next problem to generate a circulant matrix and has the following features.
If m is a scaler then y(n) is circularly shifted sequence (or array). If m is a vector then y(n) is a matrix,
each row of which is a circular shift in x(n) corresponding to entries in the vector m.
function y = cirshftf(x,m,N)
% Circular shift of m samples wrt size N in sequence x: (freq domain)
% -------------------------------------------------------------------
% function y=cirshift(x,m,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, 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, vector, or matrix
[Rm,Cm] = size(m);
if Rm > Cm
m = m’; % make sure that m is a row vector
end
[Rm,Cm] = size(m);
if Rm > 1
error(’*** m must be a vector ***’) % stop if m is a matrix
end
% Check whether x is scalar, vector, or matrix
[Rx,Cx] = size(x);
if Rx > Cx
x = x’; % make sure that x is a row vector
end
[Rx,Cx] = size(x);
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
© 2012 Cengage Learning. All Rights Reserved. This edition is intended for use outside of the U.S. only, with content that may be
different from the U.S. Edition. May not be scanned, copied, duplicated, or posted to a publicly accessible website, in whole or in part.
S OLUTIONS M ANUAL FOR E SSENTIALS OF D IGITAL S IGNAL P ROCESSING U SING MATLAB 3 E 233
x=[x zeros(1,N-length(x))];
X=dft(x,N);
X=ones(Cm,1)*X;
WN=exp(-2*j*pi/N);
k=[0:1:N-1];
Y=(WN.^(m’ * k)).*X;
y=real(conj(dfs(conj(Y),N)))/N;
M ATLAB verification:
(a) x(n) = {5, 4, 3, 2, 1, 0, 0, 1, 2, 3, 4}, 0 ≤ n ≤ 10; m = −5, N = 12.
↑
x = [5,4,3,2,1,0,0,1,2,3,4,5];
m = -5; N = 12;
y = cirshftf(x,m,N); y = real(y)
y =
0 0 1 2 3 4 5 5 4 3 2 1
(b) x(n) = {5, 4, 3, 2, 1, 0, 0, 1, 2, 3, 4}, 0 ≤ n ≤ 10; m = 8, N = 15
↑
x = [5,4,3,2,1,0,0,1,2,3,4,5];
m = 8; N = 15;
y = cirshftf(x,m,N); y = real(y)
y =
1 2 3 4 5 0 0 0 5 4 3 2
1 0 0
© 2012 Cengage Learning. All Rights Reserved. This edition is intended for use outside of the U.S. only, with content that may be
different from the U.S. Edition. May not be scanned, copied, duplicated, or posted to a publicly accessible website, in whole or in part.
234 S OLUTIONS M ANUAL FOR E SSENTIALS OF D IGITAL S IGNAL P ROCESSING U SING MATLAB 3 E
Therefore,
−1 N −1 N −1
1 1
N
X (k) X ∗ (k) =
2 2
|x (n)| = |X (k)|
n=0
N N
k=0 k=0
M ATLAB verification:
x = [5,4,3,2,1,0,0,1,2,3,4,5]; N = length(x);
% power of x(n) in the time-domain
power_x = sum(x.*conj(x))
power_x =
110
power_X =
110
© 2012 Cengage Learning. All Rights Reserved. This edition is intended for use outside of the U.S. only, with content that may be
different from the U.S. Edition. May not be scanned, copied, duplicated, or posted to a publicly accessible website, in whole or in part.
S OLUTIONS M ANUAL FOR E SSENTIALS OF D IGITAL S IGNAL P ROCESSING U SING MATLAB 3 E 235
P5.18 Let X(k) and Y (k) be 10-point DFTs of two 10-point sequences x(n) and y(n), respectively where
© 2012 Cengage Learning. All Rights Reserved. This edition is intended for use outside of the U.S. only, with content that may be
different from the U.S. Edition. May not be scanned, copied, duplicated, or posted to a publicly accessible website, in whole or in part.
236 S OLUTIONS M ANUAL FOR E SSENTIALS OF D IGITAL S IGNAL P ROCESSING U SING MATLAB 3 E
© 2012 Cengage Learning. All Rights Reserved. This edition is intended for use outside of the U.S. only, with content that may be
different from the U.S. Edition. May not be scanned, copied, duplicated, or posted to a publicly accessible website, in whole or in part.
S OLUTIONS M ANUAL FOR E SSENTIALS OF D IGITAL S IGNAL P ROCESSING U SING MATLAB 3 E 237
Y1 =
Columns 1 through 4
-0.3090 - 0.9511i 0.3090 - 0.9511i 0.8090 - 0.5878i 1.0000 + 0.0000i
Columns 5 through 8
0.8090 + 0.5878i 0.3090 + 0.9511i -0.3090 + 0.9511i -0.8090 + 0.5878i
Columns 9 through 10
-1.0000 -0.8090 - 0.5878i
difference =
3.3880e-015
5. y(n) = x(n)(10)x((−n))1 0: Circular convolution with circularly-folded sequence. M ATLAB script:
k = 0:9; X = exp(j*0.2*pi*k); N = length(X);
Y = circfold(X,N); Y = X.*Y
% verification
x = real(idft(X,N)); y = circfold(x,N); y = circonvt(x,y,N); Y1 = dft(y,N)
difference = abs(max(Y-Y1))
Y =
Columns 1 through 4
1.0000 - 0.0000i 1.0000 - 0.0000i 1.0000 + 0.0000i 1.0000 - 0.0000i
Columns 5 through 8
1.0000 - 0.0000i 1.0000 - 0.0000i 1.0000 - 0.0000i 1.0000 + 0.0000i
Columns 9 through 10
1.0000 1.0000 + 0.0000i
Y1 =
Columns 1 through 4
1.0000 + 0.0000i 1.0000 - 0.0000i 1.0000 - 0.0000i 1.0000 - 0.0000i
Columns 5 through 8
1.0000 + 0.0000i 1.0000 + 0.0000i 1.0000 - 0.0000i 1.0000 - 0.0000i
Columns 9 through 10
1.0000 - 0.0000i 1.0000 - 0.0000i
difference =
4.7761e-015
© 2012 Cengage Learning. All Rights Reserved. This edition is intended for use outside of the U.S. only, with content that may be
different from the U.S. Edition. May not be scanned, copied, duplicated, or posted to a publicly accessible website, in whole or in part.
238 S OLUTIONS M ANUAL FOR E SSENTIALS OF D IGITAL S IGNAL P ROCESSING U SING MATLAB 3 E
P5.19 Let X(k) be an N -point DFT of an N -point sequence x(n). Let N = 2μν where μ and ν are integers.
1. It is given that x(n) = x(n + ν) for all n. Let n = m + pν; 0 ≤ m ≤ ν − 1, 0 ≤ p ≤ (2μ − 1), then
x(n) = x(n + ν) ⇒ x(m + pν) = x(m), 0 ≤ m ≤ ν − 1, 0 ≤ p ≤ (2μ − 1) (5.1)
Now the DFT X(k) can be written as
N −1 ν−1
2μ−1 ν−1
2μ−1
[. .. (5.1)]
(m+pν)k
X(k) = x(n)WNnk = x(m + pν)WN = x(m) WNmk WNpνk
n=0 p=0 m=0 p=0 m=0
ν−1
2μ−1
ν−1
2μ−1 " #
p ν−1
1 − WNN k
= x(m) WNmk WNpνk = x(m) WNmk WNνk = x(m) WNmk
m=0 p=0 m=0 p=0 m=0
1 − WNνk
$ %
ν−1
1 − WNN k Non-zero, k = (2μ) for 0 ≤ ≤ ν − 1;
= x(m) WNmk =
1 − WN
N (k/2μ) 0, k= (2μ) for 0 ≤ ≤ ν − 1.
m=0
Verification for x(n) = {1, −2, 3, 1, −2, 3, 1, −2, 3, 1, −2, 3, 1, −2, 3, 1, −2, 3}.
x = [1,-2,3,1,-2,3,1,-2,3,1,-2,3,1,-2,3,1,-2,3]; N = length(x); X = dft(x,N)
X =
12.0000 0.0000 - 0.0000i -0.0000 + 0.0000i 0.0000 + 0.0000i
0.0000 0.0000 + 0.0000i 3.0000 +25.9808i -0.0000 - 0.0000i
-0.0000 + 0.0000i -0.0000 - 0.0000i -0.0000 - 0.0000i -0.0000 - 0.0000i
3.0000 -25.9808i 0.0000 + 0.0000i 0.0000 0.0000 - 0.0000i
0.0000 - 0.0000i 0.0000 - 0.0000i
2. It is given that x(n) = −x(n + ν) for all n. Let n = m + pν; 0 ≤ m ≤ ν − 1, 0 ≤ p ≤ (2μ − 1), then
x(n) = −x(n + ν) ⇒ x(m + pν) = (−1)p x(m), 0 ≤ m ≤ ν − 1, 0 ≤ p ≤ (2μ − 1) (5.2)
Now the DFT X(k) can be written as
N −1 ν−1
2μ−1 ν−1
2μ−1
[. .. (5.2)]
(m+pν)k
X(k) = x(n)WNnk = x(m + pν)WN = (−1)p x(m) WNmk WNpνk
n=0 p=0 m=0 p=0 m=0
ν−1
2μ−1
ν−1 &
2μ−1
−N/2
'p
−N/2
= x(m) WNmk (−1)p WNpνk = x(m) WNmk WN WNνk [. .. − 1 = WN ]
m=0 p=0 m=0 p=0
$ %
ν−1
1 − WN
N (k−2)
= 0, k = 2μ + 2 = 2(μ + 1), 0 ≤ ≤ ν − 1;
= x(m) WNmk =
1−
N (k−2)/(2μ)
WN 0, k = 2μ + 2 = 2(μ + 1), 0 ≤ ≤ ν − 1.
m=0
Verification for x(n) = {1, −2, 3, −1, 2, −3, 1, −2, 3, −1, 2, −3, 1, −2, 3, −1, 2, −3}.
x = [1,-2,3,-1,2,-3,1,-2,3,-1,2,-3,1,-2,3,-1,2,-3]; N = length(x); X = dft(x,N)
X =
0 -0.0000 -0.0000 + 0.0000i -9.0000 - 5.1962i
0.0000 - 0.0000i 0.0000 - 0.0000i -0.0000 - 0.0000i -0.0000 - 0.0000i
0.0000 - 0.0000i 36.0000 + 0.0000i -0.0000 + 0.0000i -0.0000 + 0.0000i
-0.0000 + 0.0000i -0.0000 + 0.0000i -0.0000 + 0.0000i -9.0000 + 5.1962i
-0.0000 - 0.0000i -0.0000 - 0.0000i
© 2012 Cengage Learning. All Rights Reserved. This edition is intended for use outside of the U.S. only, with content that may be
different from the U.S. Edition. May not be scanned, copied, duplicated, or posted to a publicly accessible website, in whole or in part.
S OLUTIONS M ANUAL FOR E SSENTIALS OF D IGITAL S IGNAL P ROCESSING U SING MATLAB 3 E 239
P5.20 Let X(k) be an N -point DFT of an N -point sequence x(n). Let N = 4ν where ν is an integer.
1. It is given that x(n) = x(n + ν) for all n. Let n = m + pν; 0 ≤ m ≤ ν − 1, 0 ≤ p ≤ 3, then
N −1
3 ν−1
3 ν−1
[. .. (5.3)]
(m+pν)k
X(k) = x(n)WNnk = x(m + pν)WN = x(m) WNmk WNpνk
n=0 p=0 m=0 p=0 m=0
ν−1
3
ν−1
3 " #
p ν−1
1 − WNN k
= x(m) WNmk WNpνk = x(m) WNmk WNνk = x(m) WNmk
m=0 p=0 m=0 p=0 m=0
1 − WNνk
$ %
ν−1
1 − WNN k Non-zero, k = 4 for 0 ≤ ≤ ν − 1;
= x(m) WNmk =
1 − WN
N (k/4) 0, k= 4 for 0 ≤ ≤ ν − 1.
m=0
N −1
3 ν−1
3 ν−1
[. .. (5.4)]
(m+pν)k
X(k) = x(n)WNnk = x(m + pν)WN = (−1)p x(m) WNmk WNpνk
n=0 p=0 m=0 p=0 m=0
ν−1
3
ν−1 3 &
'p
−N/2 −N/2
= x(m) WNmk (−1)p WNpνk = x(m) WNmk WN WNνk [. .. − 1 = WN ]
m=0 p=0 m=0 p=0
$ %
ν−1 N (k−2)
1 − WN Non-zero, k = 4 + 2 for 0 ≤ ≤ ν − 1;
= x(m) WNmk =
ν(k−2)
1 − WN 0, k= 4 + 2 for 0 ≤ ≤ ν − 1.
m=0
Verification for x(n) = {1, 2, 3, −1, −2, −3, 1, 2, 3, −1, −2, −3}.
x = [1,2,3,-1,-2,-3,1,2,3,-1,-2,-3]; N = length(x); X = dft(x,N)
X =
0 0 2.0000 -17.3205i 0.0000 + 0.0000i
0 0 8.0000 + 0.0000i -0.0000 + 0.0000i
0 0 2.0000 +17.3205i -0.0000 - 0.0000i
© 2012 Cengage Learning. All Rights Reserved. This edition is intended for use outside of the U.S. only, with content that may be
different from the U.S. Edition. May not be scanned, copied, duplicated, or posted to a publicly accessible website, in whole or in part.
240 S OLUTIONS M ANUAL FOR E SSENTIALS OF D IGITAL S IGNAL P ROCESSING U SING MATLAB 3 E
P5.21 Let X(k) be an N -point DFT of an N -point sequence x(n). Let N be an even integer.
1. Given that x(n) = x(n + N/2) for all n, consider
N −1
N/2−1
N −1
X(k) = x(n)WNnk = x(n)WNnk + x(n)WNnk
n=0 n=0 n=N/2
N/2−1
N/2−1
[. .. n → n + N/2]
(n+N/2)k
= x(n)WNnk + x(n + N/2)WN
n=0 n=0
N/2−1
N/2−1
[. .. x(n) = x(n + N/2)]
N k/2
= x(n)WNnk + x(n)WNnk WN
n=0 n=0
N/2−1
0, k odd;
[. .. WN = −1] =
k N/2
= x(n) 1 + (−1) WNnk
Non-zero, k even.
n=0
N −1
N/2−1
N −1
X(k) = x(n)WNnk = x(n)WNnk + x(n)WNnk
n=0 n=0 n=N/2
N/2−1
N/2−1
[. .. n → n + N/2]
(n+N/2)k
= x(n)WNnk + x(n + N/2)WN
n=0 n=0
N/2−1
N/2−1
[. .. x(n) = −x(n + N/2)]
N k/2
= x(n)WNnk − x(n)WNnk WN
n=0 n=0
N/2−1
[. .. WN
N/2
= x(n) 1 − (−1)k WNnk = −1]
n=0
0, k even;
=
Non-zero, k odd.
© 2012 Cengage Learning. All Rights Reserved. This edition is intended for use outside of the U.S. only, with content that may be
different from the U.S. Edition. May not be scanned, copied, duplicated, or posted to a publicly accessible website, in whole or in part.
S OLUTIONS M ANUAL FOR E SSENTIALS OF D IGITAL S IGNAL P ROCESSING U SING MATLAB 3 E 241
P5.22 Let
A cos(2πn/N ), 0≤n≤N −1
x(n) = = A cos(2πn/N )RN (n)
0, elsewhere
where is an integer. Notice that x(n) contains exactly periods (or cycles) of the cosine waveform in N
samples. This is a windowed cosine sequence containing no leakage.
1. Consider the DFT X(k) of x(n) which is given by
N −1
N −1
2πn
x(n) e−j N kn = e−j N kn ,
2π 2π
X(k) = A cos 0≤k ≤N −1
n=0 n=0
N
A j 2π n
N −1
e N + e−j N n e−j N kn ,
2π 2π
= 0≤k ≤N −1
2 n=0
N −1 N −1
A −j 2π (k−)n A −j 2π (k+)n
= e N + e N , 0≤k ≤N −1
2 n=0 2 n=0
AN AN
= δ (k − ) + δ (k − N + ) ; 0 ≤ k ≤ (N − 1) , 0<<N
2 2
which is a real-valued sequence.
2. If = 0, then the DFT X(k) is given by
N −1
N −1
x(n) e−j N kn = A e−j N kn ,
2π 2π
X(k) = 0≤k ≤N −1
n=0 n=0
= AN δ(k); 0 ≤ k ≤ (N − 1)
3. If < 0 or > N , then we must replace it by (())N in the result of part 1., i.e.
AN AN
X(k) = δ [k − (())N ] + δ [k − N + (())N ] ; 0 ≤ k ≤ (N − 1)
2 2
© 2012 Cengage Learning. All Rights Reserved. This edition is intended for use outside of the U.S. only, with content that may be
different from the U.S. Edition. May not be scanned, copied, duplicated, or posted to a publicly accessible website, in whole or in part.
242 S OLUTIONS M ANUAL FOR E SSENTIALS OF D IGITAL S IGNAL P ROCESSING U SING MATLAB 3 E
4. Verification of the results of parts 1., 2., and 3. above using M ATLAB and the following sequences:
(a) x1 (n) = 3 cos(0.04πn)R200 (n):
N = 200; n = 0:N-1; x1 = 3*cos(0.04*pi*n); l = 4;
k = 0:N-1; X1 = real(fft(x1,N));
Hf_1 = figure(’Units’,’inches’,’position’,[1,1,6,4],...
’color’,[0,0,0],’paperunits’,’inches’,’paperposition’,[0,0,6,4]);
set(Hf_1,’NumberTitle’,’off’,’Name’,’P5.22.4(a)’);
subplot(2,1,1); H_s1 = stem(n,x1,’g’,’filled’); set(H_s1,’markersize’,1);
title(’Sequence: {\itx}_1({\itn})’,’fontsize’,10);
ylabel(’Amplitude’); axis([-1,N,-4,4]); xlabel(’\itn’);
subplot(2,1,2); H_s2 = stem(n,X1,’r’,’filled’); set(H_s2,’markersize’,2);
title(’DFT: {\itX}_1({\itk})’,’fontsize’,10);
ylabel(’Amplitude’); axis([-1,N,-10,310]); xlabel(’\itk’);
set(gca,’xtick’,[0,l,N-l],’ytick’,[0,300])
The sequence x1 (n) and its DFT X1 (k) are shown in Figure 5.14.
Sequence: x1(n)
4
2
Amplitude
−2
−4
0 20 40 60 80 100 120 140 160 180 200
n
DFT: X1(k)
300
Amplitude
0
04 196
k
Figure 5.14: The signal x1 (n) and its DFT X1 (k) in Problem P5.22.4(a)
© 2012 Cengage Learning. All Rights Reserved. This edition is intended for use outside of the U.S. only, with content that may be
different from the U.S. Edition. May not be scanned, copied, duplicated, or posted to a publicly accessible website, in whole or in part.
S OLUTIONS M ANUAL FOR E SSENTIALS OF D IGITAL S IGNAL P ROCESSING U SING MATLAB 3 E 243
Sequence: x2(n)
6
4
Amplitude
0 5 10 15 20 25 30 35 40 45 50
n
DFT: X2(k)
250
Amplitude
0
0 49
k
Figure 5.15: The signal x2 (n) and its DFT X2 (k) in Problem P5.22.4(b)
© 2012 Cengage Learning. All Rights Reserved. This edition is intended for use outside of the U.S. only, with content that may be
different from the U.S. Edition. May not be scanned, copied, duplicated, or posted to a publicly accessible website, in whole or in part.
244 S OLUTIONS M ANUAL FOR E SSENTIALS OF D IGITAL S IGNAL P ROCESSING U SING MATLAB 3 E
Sequence: x3(n)
5
4
Amplitude
3
2
1
0
−1
0 10 20 30 40 50 60 70 80 90 100
n
DFT: X3(k)
100
Amplitude
0
0 25 50 75 99
k
Figure 5.16: The signal x3 (n) and its DFT X3 (k) in Problem P5.22.4(c)
© 2012 Cengage Learning. All Rights Reserved. This edition is intended for use outside of the U.S. only, with content that may be
different from the U.S. Edition. May not be scanned, copied, duplicated, or posted to a publicly accessible website, in whole or in part.
S OLUTIONS M ANUAL FOR E SSENTIALS OF D IGITAL S IGNAL P ROCESSING U SING MATLAB 3 E 245
Sequence: x4(n)
1
0.5
Amplitude
−0.5
−1
0 10 20 30 40 50 60
n
DFT: X4(k)
32
Amplitude
0 14 50 63
k
Figure 5.17: The signal x4 (n) and its DFT X4 (k) in Problem P5.22.4(d)
© 2012 Cengage Learning. All Rights Reserved. This edition is intended for use outside of the U.S. only, with content that may be
different from the U.S. Edition. May not be scanned, copied, duplicated, or posted to a publicly accessible website, in whole or in part.
246 S OLUTIONS M ANUAL FOR E SSENTIALS OF D IGITAL S IGNAL P ROCESSING U SING MATLAB 3 E
Sequence: x5(n)
1
0.5
Amplitude
−0.5
−1
0 5 10 15 20 25 30 35 40
n
DFT: X5(k)
20
Amplitude
0 2 38 40
k
© 2012 Cengage Learning. All Rights Reserved. This edition is intended for use outside of the U.S. only, with content that may be
different from the U.S. Edition. May not be scanned, copied, duplicated, or posted to a publicly accessible website, in whole or in part.
S OLUTIONS M ANUAL FOR E SSENTIALS OF D IGITAL S IGNAL P ROCESSING U SING MATLAB 3 E 247
N −1
N −1
−j ( 2π
N )nk
2π 2π
X(k) = x(n)e =A cos(ω0 n) cos nk − j sin nk
n=0 n=0
N N
N −1
N −1
2π 2π
XR (k) + jXI (k) = A cos(ω0 n) cos nk − jA cos(ω0 n) sin nk
n=0
N n=0
N
Hence
N −1
2π
XR (k) = A cos(ω0 n) cos nk (5.5)
n=0
N
N −1
2π
XI (k) = −A cos(ω0 n) sin nk (5.6)
n=0
N
−1 N −1
A
N
2π 2π 2π
XR (k) = A cos(ω0 n) cos nkcos ω0 n −
= nk + cos ω0 n + nk
n=0
2 n=0N N N
N −1
A 2π 2π
= cos 2πf0 n − nk + cos 2πf0 n + nk [. .. ω0 = 2πf0 ]
2 n=0 N N
N −1 " # " #
A 2π 2π
= cos (f0 N − k)n + cos (f0 N + k)n
2 n=0 N N
N −1 " # " #
A 2π 2π
= cos (k − f0 N )n + cos {k − (N − f0 N )}n , 0 ≤ k < N (5.7)
2 n=0 N N
−1 N −1 N −1
1 j ( 2π 1 −j ( 2π
N
2π 1 1 − ej2πv 1 1 − e−j2πv
cos vn = e N )vn + e N )vn = +
n=0
N 2 n=0 2 n=0 2 1 − ej 2π
N v 2 1 − e−j 2π
N v
Now substituting (5.8) in the first term of (5.7) with v = (k − f0 N ) and in the second term of (5.7) with
v = (k − [N − f0 N ]), we obtain the desired result
A π(N − 1) sin[π(f0 N − k)]
XR (k) = cos (k − f0 N )
2 N π
sin[ N (f0 N − k)]
A π(N − 1) sin{π(k − [N − f0 N ])}
+ cos (k − [N − f0 N ]) (5.9)
2 N π
sin[ N (f0 N − k)]
© 2012 Cengage Learning. All Rights Reserved. This edition is intended for use outside of the U.S. only, with content that may be
different from the U.S. Edition. May not be scanned, copied, duplicated, or posted to a publicly accessible website, in whole or in part.
248 S OLUTIONS M ANUAL FOR E SSENTIALS OF D IGITAL S IGNAL P ROCESSING U SING MATLAB 3 E
A sin[π(f N − k)]
sin π(NN−1) (k − f0 N )
0
XI (k) = −
2 π
sin[ N (f0 N − k)]
A sin{π(k − [N − f N ])}
− sin π(NN−1) (k − [N − f0 N ])
0
(5.10)
2 π
sin[ N (f0 N − k)]
2. 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 prop-
erty of cosines. It is a natural result due to the fact that bandlimited periodic cosines are sampled over
noninteger periods. Due to this fact, the periodic extension of x(n) does not result in a continuation of the
cosine waveform but has a jump at every N interval. This jump results in the leakage of one frequency
into the abducent frequencies and hence the result of the Problem P5.22.1 do not apply.
3. Verification of the leakage property using x(n) = cos (5πn/99) R200 (n): The sequence x(n), the real-
part of its DFT XR (k), and the imaginary part of its DFT XI (k) are shown in Figure 5.19.
Sequence: x(n)
1
0.5
Amplitude
−0.5
−1
0 20 40 60 80 100 120 140 160 180 200
n
Real−part of the DFT: XR(k)
100
Amplitude
0
−10
0 5 100 195
k
Imaginary−part of the DFT: X (k)
I
20
Amplitude
−20
0 5 100 195
k
© 2012 Cengage Learning. All Rights Reserved. This edition is intended for use outside of the U.S. only, with content that may be
different from the U.S. Edition. May not be scanned, copied, duplicated, or posted to a publicly accessible website, in whole or in part.
S OLUTIONS M ANUAL FOR E SSENTIALS OF D IGITAL S IGNAL P ROCESSING U SING MATLAB 3 E 249
P5.24 Let
A sin(2πn/N ), 0≤n≤N −1
x(n) = = A sin(2πn/N )RN (n)
0, elsewhere
where is an integer. Notice that x(n) contains exactly periods (or cycles) of the sine waveform in N
samples. This is a windowed sine sequence containing no leakage.
1. Consider the DFT X(k) of x(n) which is given by
N −1
N −1
2πn
x(n) e−j N kn = e−j N kn ,
2π 2π
X(k) = A sin 0≤k ≤N −1
n=0 n=0
N
A j 2π n
N −1
e N − e−j N n e−j N kn ,
2π 2π
= 0≤k ≤N −1
j2 n=0
N −1 N −1
A −j 2π (k−)n A −j 2π (k+)n
= e N − e N , 0≤k ≤N −1
j2 n=0 2 n=0
AN AN
= δ (k − ) − δ(k − N + ); 0 ≤ k ≤ (N − 1), 0<<N
j2 j2
which is a purely imaginary-valued sequence.
2. If = 0, then the DFT X(k) is given by
N −1
N −1
x(n) e−j N kn = 0 e−j N kn ,
2π 2π
X(k) = 0 ≤ k ≤ (N − 1)
n=0 n=0
= 0; 0 ≤ k ≤ (N − 1)
3. If < 0 or > N , then we must replace it by (())N in the result of part 1., i.e.
AN AN
X(k) = δ [k − (())N ] − δ [k − N + (())N ] ; 0 ≤ k ≤ (N − 1)
j2 j2
© 2012 Cengage Learning. All Rights Reserved. This edition is intended for use outside of the U.S. only, with content that may be
different from the U.S. Edition. May not be scanned, copied, duplicated, or posted to a publicly accessible website, in whole or in part.
250 S OLUTIONS M ANUAL FOR E SSENTIALS OF D IGITAL S IGNAL P ROCESSING U SING MATLAB 3 E
4. Verification of the results of parts 1., 2., and 3. above using M ATLAB and the following sequences:
(a) x1 (n) = 3 sin(0.04πn)R200 (n):
N = 200; n = 0:N-1; x1 = 3*sin(0.04*pi*n); l = 4;
k = 0:N-1; X1 = imag(fft(x1,N));
Hf_1 = figure(’Units’,’inches’,’position’,[1,1,6,4],...
’color’,[0,0,0],’paperunits’,’inches’,’paperposition’,[0,0,6,4]);
set(Hf_1,’NumberTitle’,’off’,’Name’,’P5.24.4(a)’);
subplot(2,1,1); H_s1 = stem(n,x1,’g’,’filled’); set(H_s1,’markersize’,1);
title(’Sequence: {\itx}_1({\itn})’,’fontsize’,10);
ylabel(’Amplitude’); axis([-1,N,-4,4]); xlabel(’\itn’);
subplot(2,1,2); H_s2 = stem(n,X1,’r’,’filled’); set(H_s2,’markersize’,2);
title(’DFT: {\itX}_1({\itk})’,’fontsize’,10);
ylabel(’Amplitude’); axis([-1,N,-350,350]); xlabel(’\itk’);
set(gca,’xtick’,[0,l,N-l],’ytick’,[-300,0,300])
The sequence x1 (n) and its DFT X1 (k) are shown in Figure 5.20.
Sequence: x1(n)
4
2
Amplitude
−2
−4
0 20 40 60 80 100 120 140 160 180 200
n
DFT: X1(k)
300
Amplitude
−300
04 196
k
Figure 5.20: The signal x1 (n) and its DFT X1 (k) in Problem P5.24.4(a)
© 2012 Cengage Learning. All Rights Reserved. This edition is intended for use outside of the U.S. only, with content that may be
different from the U.S. Edition. May not be scanned, copied, duplicated, or posted to a publicly accessible website, in whole or in part.
S OLUTIONS M ANUAL FOR E SSENTIALS OF D IGITAL S IGNAL P ROCESSING U SING MATLAB 3 E 251
The sequence x1 (n) and its DFT X1 (k) are shown in Figure 5.21.
Sequence: x2(n)
1
0.5
Amplitude
−0.5
−1
0 5 10 15 20 25 30 35 40 45 50
n
DFT: X2(k)
1
Amplitude
−1
0 49
k
Figure 5.21: The signal x1 (n) and its DFT X1 (k) in Problem P5.24.4(b)
© 2012 Cengage Learning. All Rights Reserved. This edition is intended for use outside of the U.S. only, with content that may be
different from the U.S. Edition. May not be scanned, copied, duplicated, or posted to a publicly accessible website, in whole or in part.
252 S OLUTIONS M ANUAL FOR E SSENTIALS OF D IGITAL S IGNAL P ROCESSING U SING MATLAB 3 E
Sequence: x3(n)
3
2
Amplitude
1
0
−1
−2
−3
0 10 20 30 40 50 60 70 80 90 100
n
DFT: X3(k)
100
Amplitude
−100
0 25 50 75 99
k
Figure 5.22: The signal x1 (n) and its DFT X1 (k) in Problem P5.24.4(c)
© 2012 Cengage Learning. All Rights Reserved. This edition is intended for use outside of the U.S. only, with content that may be
different from the U.S. Edition. May not be scanned, copied, duplicated, or posted to a publicly accessible website, in whole or in part.
S OLUTIONS M ANUAL FOR E SSENTIALS OF D IGITAL S IGNAL P ROCESSING U SING MATLAB 3 E 253
Sequence: x4(n)
1
0.5
Amplitude
−0.5
−1
0 10 20 30 40 50 60
n
DFT: X4(k)
32
Amplitude
−32
0 14 50 63
k
Figure 5.23: The signal x1 (n) and its DFT X1 (k) in Problem P5.24.4(d)
© 2012 Cengage Learning. All Rights Reserved. This edition is intended for use outside of the U.S. only, with content that may be
different from the U.S. Edition. May not be scanned, copied, duplicated, or posted to a publicly accessible website, in whole or in part.
254 S OLUTIONS M ANUAL FOR E SSENTIALS OF D IGITAL S IGNAL P ROCESSING U SING MATLAB 3 E
Sequence: x5(n)
10
5
Amplitude
−5
−10
0 2 4 6 8 10 12 14 16 18 20
n
DFT: X5(k)
70
Amplitude
−70
0 1 19 20
k
Figure 5.24: The signal x1 (n) and its DFT X1 (k) in Problem P5.24.4(e)
© 2012 Cengage Learning. All Rights Reserved. This edition is intended for use outside of the U.S. only, with content that may be
different from the U.S. Edition. May not be scanned, copied, duplicated, or posted to a publicly accessible website, in whole or in part.
S OLUTIONS M ANUAL FOR E SSENTIALS OF D IGITAL S IGNAL P ROCESSING U SING MATLAB 3 E 255
N −1
N −1
−j ( 2π
N )nk
2π 2π
X(k) = x(n)e =A sin(ω0 n) cos nk − j sin nk
n=0 n=0
N N
N −1
N −1
2π 2π
XR (k) + jXI (k) = A sin(ω0 n) cos nk − jA sin(ω0 n) sin nk
n=0
N n=0
N
Hence
N −1
2π
XR (k) = A sin(ω0 n) cos nk (5.11)
n=0
N
N −1
2π
XI (k) = −A sin(ω0 n) sin nk (5.12)
n=0
N
−1
N −1
A
N
2π 2π 2π
XR (k) = A sin(ω0 n) cos nk sin ω0 n −
= nk + sin ω0 n + nk
n=0
N2 n=0 N N
N −1
A 2π 2π
= sin 2πf0 n − nk + sin 2πf0 n + nk [. .. ω0 = 2πf0 ]
2 n=0 N N
N −1 " # " #
A 2π 2π
= sin (f0 N − k)n + sin (f0 N + k)n
2 n=0 N N
N −1 " # " #
A 2π 2π
= − sin (k − f0 N )n + sin {k − (N − f0 N )}n , 0 ≤ k < N (5.13)
2 n=0 N N
−1 N −1 N −1
1 j ( 2π 1 −j ( 2π
N
2π 1 1 − ej2πv 1 1 − e−j2πv
sin vn = e N )vn − e N )vn = −
n=0
N j2 n=0 j2 n=0 j2 1 − ej 2π
N v j2 1 − e−j 2π
N v
Now substituting (5.14) in the first term of (5.13) with v = (k − f0 N ) and in the second term of (5.13)
with v = (k − [N − f0 N ]), we obtain the desired result
A π(N − 1) sin[π(f0 N − k)]
XR (k) = − sin (k − f0 N )
2 N π
sin[ N (f0 N − k)]
A π(N − 1) sin{π(k − [N − f0 N ])}
+ sin (k − [N − f0 N ]) (5.15)
2 N π
sin{ N (f0 N − k)}
© 2012 Cengage Learning. All Rights Reserved. This edition is intended for use outside of the U.S. only, with content that may be
different from the U.S. Edition. May not be scanned, copied, duplicated, or posted to a publicly accessible website, in whole or in part.
256 S OLUTIONS M ANUAL FOR E SSENTIALS OF D IGITAL S IGNAL P ROCESSING U SING MATLAB 3 E
2. The above result is the leakage property of sines. 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. It is a
natural result due to the fact that bandlimited periodic sines are sampled over noninteger periods. Due to
this fact, the periodic extension of x(n) does not result in a continuation of the sine waveform but has a
jump at every N interval. This jump results in the leakage of one frequency into the abducent frequencies
and hence the result of Problem P5.24.1 do not apply.
3. Verification of the leakage property using x(n) = sin(5πn/99)R100 (n): The sequence x(n), the real-part
of its DFT XR (k), and the imaginary part of its DFT XI (k) are shown in Figure 5.25.
© 2012 Cengage Learning. All Rights Reserved. This edition is intended for use outside of the U.S. only, with content that may be
different from the U.S. Edition. May not be scanned, copied, duplicated, or posted to a publicly accessible website, in whole or in part.
S OLUTIONS M ANUAL FOR E SSENTIALS OF D IGITAL S IGNAL P ROCESSING U SING MATLAB 3 E 257
Sequence: x(n)
1
0.5
Amplitude
−0.5
−1
0 10 20 30 40 50 60 70 80 90 100
n
Real−part of the DFT: XR(k)
50
Amplitude
−50
0 5 50 95
k
Imaginary−part of the DFT: XI(k)
5
Amplitude
−5
0 5 50 95
k
© 2012 Cengage Learning. All Rights Reserved. This edition is intended for use outside of the U.S. only, with content that may be
different from the U.S. Edition. May not be scanned, copied, duplicated, or posted to a publicly accessible website, in whole or in part.
258 S OLUTIONS M ANUAL FOR E SSENTIALS OF D IGITAL S IGNAL P ROCESSING U SING MATLAB 3 E
0
−40
0 2 25 48 50
−60
01 25 49
k
2. Out of the given three values, N = 99 provides almost complete cycles of both the sine and the cosine
components. Thus N = 99 provides the least amount of leakage as shown in Figure 5.27.
© 2012 Cengage Learning. All Rights Reserved. This edition is intended for use outside of the U.S. only, with content that may be
different from the U.S. Edition. May not be scanned, copied, duplicated, or posted to a publicly accessible website, in whole or in part.
S OLUTIONS M ANUAL FOR E SSENTIALS OF D IGITAL S IGNAL P ROCESSING U SING MATLAB 3 E 259
Amplitude
0
−30
0 4 49.5 95 99
−100
02 49.5 97
k
Figure 5.27: The least amount of leakage in the spectrum of the signal in Problem P5.26.2
P5.27 Using (5.49), determine and draw the signal flow graph for the N = 8 point, radix-2 decimation-in-
frequency FFT algorithm. Using this flow graph, determine the DFT of the sequence
n = + 4m; 0 ≤ ≤ 3, 0 ≤ m ≤ 1
k = q + 2p; 0 ≤ p ≤ 3, 0 ≤ q ≤ 1
3
1
X(p, q) = W8q x(, m)W2mq W4p
=0 m=0
Thus we take initial 2-point DFTs of the columns of x(p, q) and then multiply by the twiddle factors and
continue this operations. The complete flow-graph is shown in Figure 5.28.
Figure 5.29 shows signal values (in red) for x(n) = cos(πn/2), 0 ≤ n ≤ 7. From it we obtain
© 2012 Cengage Learning. All Rights Reserved. This edition is intended for use outside of the U.S. only, with content that may be
different from the U.S. Edition. May not be scanned, copied, duplicated, or posted to a publicly accessible website, in whole or in part.
260 S OLUTIONS M ANUAL FOR E SSENTIALS OF D IGITAL S IGNAL P ROCESSING U SING MATLAB 3 E
x [0] X [0]
0
W8
x [1] X [4]
–1
0
W8
x [2] X [2]
–1
2 0
W8 W8
x [3] X [6]
–1 –1
0
W8
x [4] X [1]
–1
1 0
W8 W8
x [5] X [5]
–1 –1
2 0
W8 W8
x [6] X [3]
–1 –1
3 2 0
W8 W8 W8
x [7] X [7]
–1 –1 –1
2 0
1 x [0] X [0] =0
0
0 0 W8
0 x [1] X [4] =0
–1
0
−2 W8 4
−1 x [2] X [2] =4
–1
2 0
0 W8 0 W8
0 x [3] X [6] =4
–1 –1
0
W8 0 0
1 x [4] X [1] =0
–1
1 0
W8 0 0 W8
0 x [5] X [5] =0
–1 –1
2 0
W8 0 W8 0
−1 x [6] X [3] =0
–1 –1
3 2 0
W8 0 W8 0 W8
0 x [7] X [7] =0
–1 –1 –1
Figure 5.29: The flow-graph of the 8-point DIF-FFT for x(n) = cos(πn/2) in Problem P5.27
© 2012 Cengage Learning. All Rights Reserved. This edition is intended for use outside of the U.S. only, with content that may be
different from the U.S. Edition. May not be scanned, copied, duplicated, or posted to a publicly accessible website, in whole or in part.
S OLUTIONS M ANUAL FOR E SSENTIALS OF D IGITAL S IGNAL P ROCESSING U SING MATLAB 3 E 261
P5.28 Using (5.49), determine and draw the signal flow graph for the N = 16 point, radix-4 decimation-in-time
FFT algorithm. Using this flow graph determine the DFT of the sequence
n = + 2m; 0 ≤ ≤ 1, 0 ≤ m ≤ 7
k = q + 8p; 0 ≤ p ≤ 1, 0 ≤ q ≤ 7
1
q
7
X(p, q) = W16 x(, m)W8mq W2p
=0 m=0
Thus we take initial 8-point DFTs of the rows of x(p, q) and then multiply by the twiddle factors and
continue this operations. The complete flow-graph is shown in Figure 5.30.
Figure 5.30 also shows signal values (in red) and signal flows (in heavy lines) for the computation of
X(4) when x(n) = cos(πn/2), 0 ≤ n ≤ 15. From it we obtain
© 2012 Cengage Learning. All Rights Reserved. This edition is intended for use outside of the U.S. only, with content that may be
different from the U.S. Edition. May not be scanned, copied, duplicated, or posted to a publicly accessible website, in whole or in part.
262 S OLUTIONS M ANUAL FOR E SSENTIALS OF D IGITAL S IGNAL P ROCESSING U SING MATLAB 3 E
2 4
1 x[0] X[0] 0
0
W
1
16
x[8]
−1
X[1] 0
2
0
W
1 x[4]
16
X[2] 0
−1
W160 W162
1 x[12] X[3] 0
−1 −1
−2 −4 W160 8
−1 x[2] X[4] 8
−1
0 1
W W
−1 x[10]
16
−1
16
X[5] 0
−1
−2 W 0
W 2
−1
16
0
16
x[6] X[6]
−1 −1
0 2 3
W W W
−1 0
16 16 16
x[14] X[7]
−1 −1 −1
0 0 0 0 W160
x[1]
−1
X[8] 0
0 1
W W
0
16 16
x[9]
−1 −1
X[9] 0
0
0 2
W W
0
16 16
x[5]
−1 −1
X[10] 0
W160 W162 W163
0 x[13]
−1
X[11] 0
−1 −1
0 0 W160 0 W164
0 x[3] X[12] 8
−1 −1
W160 W161 W165
0 x[11]
−1 −1 −1
X[13] 0
0 W166
0 2
W W
0
16 16
x[7]
−1 −1 −1
X[14] 0
0 2 3 7
W W W W
0
16
0
16 16 16
x[15] X[15]
−1 −1 −1 −1
© 2012 Cengage Learning. All Rights Reserved. This edition is intended for use outside of the U.S. only, with content that may be
different from the U.S. Edition. May not be scanned, copied, duplicated, or posted to a publicly accessible website, in whole or in part.
S OLUTIONS M ANUAL FOR E SSENTIALS OF D IGITAL S IGNAL P ROCESSING U SING MATLAB 3 E 263
P5.29 Let x(n) be a uniformly distributed random number between [−1, 1] for 0 ≤ n ≤ 106 . Let
1. Using the conv function, determine the output sequence y(n) = x(n) ∗ h(n).
M ATLAB script:
clc; close all;
N = 1000001; x = 2*rand(1,N)-1; h = cos(0.4*pi*(0:15));
%% 1. Use of the conv function
t = cputime; y1 = conv(x,h); t_conv = cputime-t
t_conv =
0.2500
y1 = y1(1:1000001);
2. Consider the overlap-and-save method of block convolution along with the FFT algorithm to implement
high-speed block convolution. Using this approach, determine y(n) with FFT sizes of 1024, 2048, and
4096.
M ATLAB script:
%% 2. Use of the hsolpsav function
% (a) FFT size = 1024
t = cputime; y2a = hsolpsav(x,h,1024); t_1024 = cputime-t
t_1024 =
0.1600
y2a = y2a(1:1000001); differencea = max(abs(y1-y2a))
differencea =
3.5527e-15
% (a) FFT size = 2048
t = cputime; y2b = hsolpsav(x,h,2048); t_2048 = cputime-t
t_2048 =
0.1300
y2b = y2b(1:1000001); differenceb = max(abs(y1-y2b))
differenceb =
3.5527e-15
% (a) FFT size = 4096
t = cputime; y2c = hsolpsav(x,h,4096); t_4096 = cputime-t
t_4096 =
0.1200
y2c = y2c(1:1000001); differencec = max(abs(y1-y2c))
differencec =
4.4409e-15
3. Compare the above approaches in terms of the convolution results and their execution times.
First, the difference between all four convolutions is negligible as indicated by the output of the M ATLAB
script. The conv function is the slowest in execution while the high-speed overlap-and-save method with
FFT size 4096 the fastest.
© 2012 Cengage Learning. All Rights Reserved. This edition is intended for use outside of the U.S. only, with content that may be
different from the U.S. Edition. May not be scanned, copied, duplicated, or posted to a publicly accessible website, in whole or in part.
264 S OLUTIONS M ANUAL FOR E SSENTIALS OF D IGITAL S IGNAL P ROCESSING U SING MATLAB 3 E
P5.30 A 512-point DFT X(k) of a real-valued sequence x(n) has the following DFT values:
© 2012 Cengage Learning. All Rights Reserved. This edition is intended for use outside of the U.S. only, with content that may be
different from the U.S. Edition. May not be scanned, copied, duplicated, or posted to a publicly accessible website, in whole or in part.
S OLUTIONS M ANUAL FOR E SSENTIALS OF D IGITAL S IGNAL P ROCESSING U SING MATLAB 3 E 265
where
1, 0 ≤ n ≤ 6
R7 (n) =
0, else
is a circularly folded and circularly shifted-by-(−1) version of the 7-point sequence {1, 2, −3, 4, −5, 0, 0}.
Hence
© 2012 Cengage Learning. All Rights Reserved. This edition is intended for use outside of the U.S. only, with content that may be
different from the U.S. Edition. May not be scanned, copied, duplicated, or posted to a publicly accessible website, in whole or in part.
266 S OLUTIONS M ANUAL FOR E SSENTIALS OF D IGITAL S IGNAL P ROCESSING U SING MATLAB 3 E
1. Using the results from Example 5.13, we can express the above signals as
⎡ ⎤ ⎡ ⎤
1 1 4 3 2
⎢ 2 ⎥ ⎢ 2 1 4 3 ⎥
x1 = ⎢ ⎥ ⎢
⎣ 2 ⎦ , 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. Such a matrix is called a circulant matrix. It is completely described by
the first column or the row.
2. Circular convolution:
⎡ ⎤⎡ ⎤ ⎡ ⎤
1 4 3 2 1 15
⎢ 2 1 4 3 ⎥ ⎢ 2 ⎥ ⎢ 12 ⎥
x 3 = X 2 x1 = ⎢ ⎥⎢ ⎥ ⎢
⎣ 3 2 1 4 ⎦⎣ 2 ⎦ = ⎣ 9 ⎦
⎥
4 3 2 1 0 14
© 2012 Cengage Learning. All Rights Reserved. This edition is intended for use outside of the U.S. only, with content that may be
different from the U.S. Edition. May not be scanned, copied, duplicated, or posted to a publicly accessible website, in whole or in part.
S OLUTIONS M ANUAL FOR E SSENTIALS OF D IGITAL S IGNAL P ROCESSING U SING MATLAB 3 E 267
function C = circulnt(x,N)
% Circulant matrix generation using vector data values
% ----------------------------------------------------
% function C = circulnt(h,N)
%
% C : Circulant matrix
% x : input sequence of length <= N
% N : size of the circular buffer
% Method: C = h((n-m) mod N);
Mx = length(x); % length of x
x = [x, zeros(N-Mx,1)]; % zero-pad x
C = zeros(N,N); % establish size of C
m = 0:N-1; % indices n and m
x = circfold(x,N); % Circular folding
C = cirshift(x,m,N); % Circular shifting
X2 =
1.0000 4.0000 3.0000 2.0000
2.0000 1.0000 4.0000 3.0000
3.0000 2.0000 1.0000 4.0000
4.0000 3.0000 2.0000 1.0000
x3 = X2*x1’; x3 = x3’
x3 =
15.0000 12.0000 9.0000 14.0000
© 2012 Cengage Learning. All Rights Reserved. This edition is intended for use outside of the U.S. only, with content that may be
different from the U.S. Edition. May not be scanned, copied, duplicated, or posted to a publicly accessible website, in whole or in part.
268 S OLUTIONS M ANUAL FOR E SSENTIALS OF D IGITAL S IGNAL P ROCESSING U SING MATLAB 3 E
function y = circonvf(x1,x2,N)
%
%function y=circonvf(x1,x2,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))
x1=[x1 zeros(1,N-length(x1))];
x2=[x2 zeros(1,N-length(x2))];
X1=fft(x1); X2=fft(x2);
y=real(ifft(X1.*X2));
x1 = [4,3,2,1]; x2 = [1,2,3,4];
x3 = circonvf(x1,x2,4)
x3 =
24 22 24 30
© 2012 Cengage Learning. All Rights Reserved. This edition is intended for use outside of the U.S. only, with content that may be
different from the U.S. Edition. May not be scanned, copied, duplicated, or posted to a publicly accessible website, in whole or in part.
S OLUTIONS M ANUAL FOR E SSENTIALS OF D IGITAL S IGNAL P ROCESSING U SING MATLAB 3 E 269
x1 (n) = {1, 3, 2, −1}; x2 (n) = {2, 1, 0, −1}; x3 (n) = x1 (n) ∗ x2 (n); x4 (n) = x1 (n) 5jx2 (n)
↑ ↑
2. Computation of x4 (n) using x3 (n) alone: The error in the two convolutions is given by
e(n)=x4 (n) − x3 (n) = x3 (n + N )
we have, for N = 5,
© 2012 Cengage Learning. All Rights Reserved. This edition is intended for use outside of the U.S. only, with content that may be
different from the U.S. Edition. May not be scanned, copied, duplicated, or posted to a publicly accessible website, in whole or in part.
270 S OLUTIONS M ANUAL FOR E SSENTIALS OF D IGITAL S IGNAL P ROCESSING U SING MATLAB 3 E
P5.36 Computation and plotting of the N -point circular convolutions between two finite-length sequences.
1. x1 (n) = sin(πn/3)R6 (n), x2 (n) = cos(πn/4)R8 (n); N = 10: M ATLAB script:
N = 10; n = 0:N-1;n1 = 0:5; x1 = sin(pi*n1/3);
n2 = 0:7; x2 = cos(pi*n2/4); x3 = circonvt(x1,x2,N);
Hf_1 = figure(’Units’,’inches’,’position’,[1,1,5,2],...
’color’,[0,0,0],’paperunits’,’inches’,’paperposition’,[0,0,5,2]);
set(Hf_1,’NumberTitle’,’off’,’Name’,’P5.36.1’);
H_s1 = stem(n,x3,’filled’); set(H_s1,’markersize’,3);
title(’Circular Convolution {\itx}_3({\itn})’,’fontsize’,10);
ylabel(’Amplitude’); xlabel(’{\itn}’); axis([-1,N,min(x3)-1,max(x3)+1]);
The sample plot is shown in Figure 5.31.
2
Amplitude
−2
−1 0 1 2 3 4 5 6 7 8 9 10
n
Figure 5.31: The sample plot in Problem P5.36.1
2. x1 (n) = cos (2πn/N ) RN (n), x2 (n) = sin (2πn/N ) RN (n); N = 32: M ATLAB script:
N = 32; n = 0:N-1;
x1 = cos(2*pi*n/N); x2 = sin(2*pi*n/N); x3 = circonvt(x1,x2,N);
Hf_2 = figure(’Units’,’inches’,’position’,[1,1,5,1.5],...
’color’,[0,0,0],’paperunits’,’inches’,’paperposition’,[0,0,5,1.5]);
set(Hf_2,’NumberTitle’,’off’,’Name’,’P5.36.2’);
H_s2 = stem(n,x3,’filled’); set(H_s2,’markersize’,3);
title(’Circular Convolution {\itx}_3({\itn})’,’fontsize’,10);
ylabel(’Amplitude’); xlabel(’{\itn}’); axis([-1,N,min(x3)-1,max(x3)+1]);
The sample plot is shown in Figure 5.32.
10
Amplitude
−10
0 5 10 15 20 25 30
n
© 2012 Cengage Learning. All Rights Reserved. This edition is intended for use outside of the U.S. only, with content that may be
different from the U.S. Edition. May not be scanned, copied, duplicated, or posted to a publicly accessible website, in whole or in part.
S OLUTIONS M ANUAL FOR E SSENTIALS OF D IGITAL S IGNAL P ROCESSING U SING MATLAB 3 E 271
n
3. x1 (n) = (0.8) RN (n), x2 (n) = (−0.8)n RN (n); N = 20: M ATLAB script:
N = 20; n = 0:N-1;
x1 = (0.8).^n; x2 = (-0.8).^n; x3 = circonvt(x1,x2,N);
Hf_3 = figure(’Units’,’inches’,’position’,[1,1,5,1.5],...
’color’,[0,0,0],’paperunits’,’inches’,’paperposition’,[0,0,5,1.5]);
set(Hf_3,’NumberTitle’,’off’,’Name’,’P5.36.3’);
H_s3 = stem(n,x3,’filled’); set(H_s3,’markersize’,3);
title(’Circular Convolution {\itx}_3({\itn})’,’fontsize’,10);
ylabel(’Amplitude’); xlabel(’{\itn}’); axis([-1,N,min(x3)-0.5,max(x3)+0.5]);
The sample plot is shown in Figure 5.33.
1
Amplitude
0.5
−0.5
0 2 4 6 8 10 12 14 16 18 20
n
300
250
200
−1 0 1 2 3 4 5 6 7 8 9 10
n
© 2012 Cengage Learning. All Rights Reserved. This edition is intended for use outside of the U.S. only, with content that may be
different from the U.S. Edition. May not be scanned, copied, duplicated, or posted to a publicly accessible website, in whole or in part.
272 S OLUTIONS M ANUAL FOR E SSENTIALS OF D IGITAL S IGNAL P ROCESSING U SING MATLAB 3 E
5. x1 (n) = (0.8)n R20 ,x2 (n) = u(n) − u(n − 40); N = 50: M ATLAB script:
N = 50; n = 0:N-1; n1 = 0:19; x1 = (0.8).^n1;
n2 = 0:39; x2 = ones(1,40); x3 = circonvt(x1,x2,N);
Hf_5 = figure(’Units’,’inches’,’position’,[1,1,5,1.5],...
’color’,[0,0,0],’paperunits’,’inches’,’paperposition’,[0,0,5,1.5]);
set(Hf_5,’NumberTitle’,’off’,’Name’,’P5.36.5’);
H_s5 = stem(n,x3,’filled’); set(H_s5,’markersize’,3);
title(’Circular Convolution {\itx}_3({\itn})’,’fontsize’,10);
ylabel(’Amplitude’); xlabel(’{\itn}’); axis([-1,N,min(x3)-1,max(x3)+1]);
0
0 5 10 15 20 25 30 35 40 45 50
n
© 2012 Cengage Learning. All Rights Reserved. This edition is intended for use outside of the U.S. only, with content that may be
different from the U.S. Edition. May not be scanned, copied, duplicated, or posted to a publicly accessible website, in whole or in part.
S OLUTIONS M ANUAL FOR E SSENTIALS OF D IGITAL S IGNAL P ROCESSING U SING MATLAB 3 E 273
N −1
N −1 N
−1
N −1
N −1
y(n) = x1 (k) x2 ((n − k))N = x1 (k) x2 ((n − k))N
n=0 n=0 k=0 k=0 n=0
−1
$k−1 −1
%
N
N
= x1 (n) x2 (n − k + N ) + x2 (n − k)
n=0 n=0 n=k
−1
$ −1 −1−k
% −1
$N −k−1 −1
%
N
N N
N
N
= x1 (n) x2 (n) + x2 (n) = x1 (n) x2 (n) + x2 (n)
n=0 n=N −k n=0 n=0 n=0 n=N −k
.N −1 / .N −1 /
= x1 (n) x2 (n)
n=0 n=0
x1 (n) = {9, 4, −1, 4, −4, −1, 8, 3}; x2 (n) = {−5, 6, 2, −7, −5, 2, 2, −2}
Consider
7
x1 (n) = {9, 4, −1, 4, −4, −1, 8, 3} ⇒ x1 (n) = 22
n=0
7
x2 (n) = {−5, 6, 2, −7, −5, 2, 2, −2} ⇒ x2 (n) = −7
n=0
7
y(n) = x1 (n) 8jx2 (n) = {14, −9, −32, −74, −7, −16, −57, 27} ⇒ y(n) = −154
n=0
Hence
. /. /
7
7
7
y(n) = −154 = (22) × (−7) = x1 (n) x2 (n)
n=0 n=0 n=0
P5.38 Let X(k) be the 8-point DFT of a 3-point sequence x(n) = {5, −4, 3}. Let Y (k) be the 8-point DFT of
↑
a sequence y(n) where Y (k) = W85k X((−k))8 . Then using the circular folding and the circular shifting
properties of the DFT, 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, 0, 0, 3, −4, 5, 0, 0}
↑
© 2012 Cengage Learning. All Rights Reserved. This edition is intended for use outside of the U.S. only, with content that may be
different from the U.S. Edition. May not be scanned, copied, duplicated, or posted to a publicly accessible website, in whole or in part.
274 S OLUTIONS M ANUAL FOR E SSENTIALS OF D IGITAL S IGNAL P ROCESSING U SING MATLAB 3 E
P5.39 Computation of (i) the N -point circular convolution x3 (n) = x1 (n) Njx2 (n), (ii) the linear convolution
x4 (n) = x1 (n) ∗ x2 (n), and (iii) the error sequence e(n) = x3 (n) − x4 (n) for the following sequences:
1. x1 (n) = {1, 1, 1, 1}, x2 (n) = cos(πn/4)R6 (n); N = 8:
x1 = [1,1,1,1]; x2 = cos(pi*[0:5]/4); N = 8; n = 0:N-1;
x3 = circonvt(x1,x2,N);
x4 = conv(x1,x2); n4 = 0:length(x4)-1;
e1 = x3 - x4(1:N); e2 = x4(N+1:end);
The plots of various signals are shown in Figure 5.36.
0
−1
−2
−3
−1 0 1 2 3 4 5 6 7 8 9
0
−1
−2
−3
−1 0 1 2 3 4 5 6 7 8 9
0
−1
−2
−3
−1 0 1 2 3 4 5 6 7 8 9
Error: x4(n+N)
2
1
Amplitude
0
−1
−2
−3
−1 0 1 2 3 4 5 6 7 8 9
n
Figure 5.36: The sample plot of various signals in Problem P5.39.1
© 2012 Cengage Learning. All Rights Reserved. This edition is intended for use outside of the U.S. only, with content that may be
different from the U.S. Edition. May not be scanned, copied, duplicated, or posted to a publicly accessible website, in whole or in part.
S OLUTIONS M ANUAL FOR E SSENTIALS OF D IGITAL S IGNAL P ROCESSING U SING MATLAB 3 E 275
5
Amplitude
−5
0 5 10 15 20 25 30
−5
0 5 10 15 20 25 30
−5
0 5 10 15 20 25 30
Error: x4(n+N)
5
Amplitude
−5
0 5 10 15 20 25 30
n
Figure 5.37: The sample plot of various signals in Problem P5.39.2
© 2012 Cengage Learning. All Rights Reserved. This edition is intended for use outside of the U.S. only, with content that may be
different from the U.S. Edition. May not be scanned, copied, duplicated, or posted to a publicly accessible website, in whole or in part.
276 S OLUTIONS M ANUAL FOR E SSENTIALS OF D IGITAL S IGNAL P ROCESSING U SING MATLAB 3 E
1
Amplitude
0.5
−0.5
0 2 4 6 8 10 12 14 16 18
1
Amplitude
0.5
−0.5
0 2 4 6 8 10 12 14 16 18
1
Amplitude
0.5
−0.5
0 2 4 6 8 10 12 14 16 18
Error: x4(n+N)
1.5
1
Amplitude
0.5
−0.5
0 2 4 6 8 10 12 14 16 18
n
© 2012 Cengage Learning. All Rights Reserved. This edition is intended for use outside of the U.S. only, with content that may be
different from the U.S. Edition. May not be scanned, copied, duplicated, or posted to a publicly accessible website, in whole or in part.
S OLUTIONS M ANUAL FOR E SSENTIALS OF D IGITAL S IGNAL P ROCESSING U SING MATLAB 3 E 277
300
Amplitude
200
100
0
0 2 4 6 8 10 12 14 16 18
300
Amplitude
200
100
0
0 2 4 6 8 10 12 14 16 18
300
Amplitude
200
100
0
0 2 4 6 8 10 12 14 16 18
Error: x4(n+N)
300
Amplitude
200
100
0
0 2 4 6 8 10 12 14 16 18
n
© 2012 Cengage Learning. All Rights Reserved. This edition is intended for use outside of the U.S. only, with content that may be
different from the U.S. Edition. May not be scanned, copied, duplicated, or posted to a publicly accessible website, in whole or in part.
278 S OLUTIONS M ANUAL FOR E SSENTIALS OF D IGITAL S IGNAL P ROCESSING U SING MATLAB 3 E
2
Amplitude
1
0
−1
−2
−1 0 1 2 3 4 5 6 7
2
Amplitude
1
0
−1
−2
−1 0 1 2 3 4 5 6 7
2
Amplitude
1
0
−1
−2
−1 0 1 2 3 4 5 6 7
Error: x4(n+N)
2
Amplitude
1
0
−1
−2
−1 0 1 2 3 4 5 6 7
n
© 2012 Cengage Learning. All Rights Reserved. This edition is intended for use outside of the U.S. only, with content that may be
different from the U.S. Edition. May not be scanned, copied, duplicated, or posted to a publicly accessible website, in whole or in part.
S OLUTIONS M ANUAL FOR E SSENTIALS OF D IGITAL S IGNAL P ROCESSING U SING MATLAB 3 E 279
P5.40 The overlap-add method of block convolution is an alternative to the overlap-save method. Let x(n) be a
long sequence of length M L where M, L 1. Divide x(n) into M segments {xm (n), m = 1, . . . , M }
each of length L
M −1
x(n), mL ≤ n ≤ (m + 1)L − 1
xm (n) = so that x(n) = xm (n)
0, elsewhere
m=0
M −1
M −1
y(n) = x(n) ∗ h(n) = xm (n) ∗ h(n) = ym (n); ym (n) = xm (n) ∗ h(n)
m=0 m=0
Clearly, ym (n) is a (2L − 1)-point sequence. 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). To use DFT for this
operation we have to choose N ≥ (2L − 1).
1. M ATLAB function to implement the overlap-add method using the circular convolution operation:
function [y] = ovrlpadd(x,h,N)
% Overlap-Add method of block convolution
% ----------------------------------------
% [y] = ovrlpadd(x,h,N)
% y = output sequence
% x = input sequence
% h = impulse response
% N = DFT length >= 2*length(h)-1
%
Lx = length(x); L = length(h); L1 = L-1;
h = [h zeros(1,N-L)];
%
M = ceil(Lx/L); % Number of blocks
x = [x, zeros(1,M*L-Lx)]; % append (M*N-Lx) zeros
Y = zeros(M,N); % Initialize Y matrix
%
% convolution with succesive blocks
for m = 0:M-1
xm = [x(m*L+1:(m+1)*L),zeros(1,N-L)];
Y(m+1,:) = circonvt(xm,h,N);
end
%
% Overlap and Add
Y = [Y,zeros(M,1)]; Y = [Y;zeros(1,N+1)];
Y1 = Y(:,1:L); Y1 = Y1’; y1 = Y1(:);
Y2 = [zeros(1,L);Y(1:M,L+1:2*L)]; Y2 = Y2’; y2 = Y2(:);
y = y1+y2; y = y’; y = removetrailzeros(y);
© 2012 Cengage Learning. All Rights Reserved. This edition is intended for use outside of the U.S. only, with content that may be
different from the U.S. Edition. May not be scanned, copied, duplicated, or posted to a publicly accessible website, in whole or in part.
280 S OLUTIONS M ANUAL FOR E SSENTIALS OF D IGITAL S IGNAL P ROCESSING U SING MATLAB 3 E
© 2012 Cengage Learning. All Rights Reserved. This edition is intended for use outside of the U.S. only, with content that may be
different from the U.S. Edition. May not be scanned, copied, duplicated, or posted to a publicly accessible website, in whole or in part.
S OLUTIONS M ANUAL FOR E SSENTIALS OF D IGITAL S IGNAL P ROCESSING U SING MATLAB 3 E 281
© 2012 Cengage Learning. All Rights Reserved. This edition is intended for use outside of the U.S. only, with content that may be
different from the U.S. Edition. May not be scanned, copied, duplicated, or posted to a publicly accessible website, in whole or in part.