You are on page 1of 14

Electrical Engineering in Context Smart

Devices Robots and Communications


1st Edition Roman Kuc Solutions
Manual
Visit to download the full and correct content document: https://testbankdeal.com/dow
nload/electrical-engineering-in-context-smart-devices-robots-and-communications-1st
-edition-roman-kuc-solutions-manual/
Chapter 9

Spectral Analysis

9.1 Problems
Problem 9.1 (Verify DFT values X0 and Xnx /2 ) Compute DFT values X0 and Xnx /2 using the direct
computation given by either Eq.(9.1) or Eq.(9.4) for

x0 = 1, x1 = −1, and xi = 0 for 2 ≤ i ≤ 63

(ans: Using Eq.(9.1)


x −1
n∑ x −1
n∑
−jωk i
Xk = xi e = xi e−j2πki/nx
i=0 i=0

Letting k = 0 makes e−jωk i = 1 for all i and gives


63
X0 = xi = x0 + x1 = 1 − 1 = 0
i=0

Letting k = nx /2 makes e−j2πki/nx = e−j2πnx i/(2nx ) = e−jπi = (−1)i for all i and gives


63
Xnx /2 = (−1)i xi = x0 − x1 = 1 + 1 = 2
i=0

Using Eq.(9.4)
x −1
n∑ x −1
n∑ x −1
n∑ x −1
n∑
Xk = xi cos(ωk i) − j xi sin(ωk i) = xi cos(2πki/nx ) − j xi sin(2πki/nx )
i=0 i=0 i=0 i=0

Letting k = 0 makes cos(0) = 1 and sin(0) = 0 for all i and gives


63
X0 = xi = x0 + x1 = 1 − 1 = 0
i=0

107

© 2015 Cengage Learning. All Rights Reserved. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part.
108 CHAPTER 9. SPECTRAL ANALYSIS

Letting k = nx /2 makes cos(πi) = (−1)i and sin(πi) = 0 for all i and gives

63
Xnx /2 = (−1)i xi = x0 − x1 = 1 + 1 = 2
i=0

Problem 9.2 (DFT of delayed unit-sample sequence) Compute |Xk | for 0 ≤ k ≤ 32 for the unit-
sample sequence delayed by two samples as
xi = di−2 for 0 ≥ i ≥ 63

(ans: Note that there is only one non-zero value, x2 = 1. Using Eq.(9.1) the i = 2 term is
x −1
n∑
Xk = xi e−jωk i = x2 e−j2πk(2/32) = (1)e−jπk/8
i=0

Using the magnitude-phase form of a complex number gives


|Xk | = 1 for all k
That is, a shift in time affects only the phase term. Here, a delay of 2 introduces a linear phase with a
negative slope.
)

Problem 9.3 (DFT of 3-sample interpolator) Compute |Xk | for 0 ≤ k ≤ 32 using


x0 = 0.5, x1 = 1, x2 = 0.5, and xi = 0 for 3 ≥ i ≥ 63
Hint: Simplify by expressing the DFT about the point of symmetry in the time domain.

(ans: Note that there are only three non-zero values. Using Eq.(9.1) gives

63
Xk = xi e−jωk i = 0.5 + e−j2πk/64 + 0.5e−j4πk/64
i=0

The point of symmetry in time is i = 1. Factoring out e−j2πk/64 from the above result gives
( )
Xk = e−j2πk/64 0.5ej2πk/64 + 1 + 0.5e−j2πk/64

Applying the Euler identity


ej2πk/64 + e−j2πk/64 = 2 cos(2πk/64)
to the previous result gives
Xk = e−j2πk/64 [1 + cos(2πk/64))]
This gives
|Xk | = 1 + cos(2πk/64)
which is a raised cosine sequence.
)

© 2015 Cengage Learning. All Rights Reserved. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part.
9.1. PROBLEMS 109

Problem 9.4 (Compute DFT values X0 and Xnx /2 ) Compute DFT values X0 and Xnx /2 using

xi = 0.9i for 0 ≥ i ≥ 63

Hint: Use the finite geometric sum formula.

(ans: Using Eq.(9.1)


x −1
n∑ x −1
n∑
Xk = xi e−jωk i = 0.9i e−j2πki/nx
i=0 i=0

Letting k = 0 makes e−jωk i = 1 for all i and gives


63
X0 = 0.9i
i=0

The finite-geometric sum formula is



n−1
1 − cn
ci =
1−c
i=0

Applying this formula with c = 0.9 gives


63
1 − 0.964 1 − 0.001
X0 = 0.9i = = = 9.99
1 − 0.9 .1
i=0

Letting k = nx /2 makes e−j2πki/nx = e−j2πnx i/(2nx ) = e−jπi = (−1)i for all i and gives


63 ∑
63
X32 = (−1)i (0.9)i = (−0.9)i
i=0 i=0

Applying the finite geometric sum formula with c = −0.9 gives


63
1 + 0.964 1 + 0.001
X32 = (−0.9)i = = = 0.527
1 + 0.9 1.9
i=0

Note that X0 ≈ 20X32 . Thus, most of the frequency content is at low frequencies.
)

Problem 9.5 (Compute DFT values X0 and Xnx /2 ) Compute DFT values X0 and Xnx /2 using

xi = (−0.9)i for 0 ≥ i ≥ 63

(ans: Using Eq.(9.1)


x −1
n∑ x −1
n∑
−jωk i
Xk = xi e = (−0.9)i e−j2πki/nx
i=0 i=0

© 2015 Cengage Learning. All Rights Reserved. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part.
110 CHAPTER 9. SPECTRAL ANALYSIS

Letting k = 0 makes e−jωk i = 1 for all i and gives


63
X0 = (−0.9)i
i=0

The finite-geometric sum formula is



n−1
1 − cn
ci =
1−c
i=0

Applying the finite geometric sum formula with c = −0.9 gives


63
1 + 0.964 1 + 0.001
X0 = (−0.9)i = = = 0.527
1 + 0.9 1.9
i=0

Letting k = nx /2 makes e−j2πki/nx = e−j2πnx i/(2nx ) = e−jπi = (−1)i for all i and gives


63 ∑
63
i
X32 = (−1) xi = (0.9)i
i=0 i=0

Applying the finite geometric sum formula with c = 0.9 gives


63
1 − 0.964 1 − 0.001
X32 = 0.9i = = = 9.99
1 − 0.9 .1
i=0

Note that X0 ≈ X32 /20. Thus, most of the frequency content is at high frequencies.
)

Problem 9.6 (Compute the power transfer function for first-order AR system) Extend Example 9.13
to compute |Hk |2 for k = 0, 1, 2, . . . , nx − 1 for an AR system with the unit-sample response as

hi = (−0.9)i for i ≥ 0

Hint: Use the infinite geometric sum formula.

(ans:

∑ ∞ (
∑ )i
i −j2πki/nx
Hk = (−0.9) e = −0.9e−j2πk/nx
i=0 i=0

The infinite-geometric sum formula is



∑ 1
ci =
1−c
i=0

Applying the finite geometric sum formula with c = −0.9e−j2πk/nx gives


1
Hk =
1 + 0.9e−j2πk/nx

© 2015 Cengage Learning. All Rights Reserved. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part.
9.1. PROBLEMS 111

The power transfer function is computed as |Hk |2 = Hk Hk∗ to give


( )( )
1 1
|Hk |2 = Hk Hk∗ =
1 + 0.9e−j2πk/nx 1 + 0.9ej2πk/nx

Performing the multiplication and applying the Euler identity gives


1 1
|Hk |2 = =
1+ 0.92 + 2(0.9) cos(2πk/nx ) 1.81 + 1.8 cos(2πk/nx )

Inserting k = 0 makes 2πk/nx = 0 and gives


1 1
|H0 |2 = = = 0.277
1.81 + 1.8 cos(0) 3.61

Inserting k = nx /2 makes 2πk/nx = π and gives


1 1 1
|Hnx /2 |2 = = = = 100
1.81 + 1.8 cos(π) 1.81 − 1.8 0.01

Note that |Hnx /2 |2 ≈ 400|H0 |2 . Thus, this is the transfer function of a high-pass filter.
)

Problem 9.7 (Padding with zeros) The convolution of two rectangular sequences, each defined by

xi = 1 for 0 ≤ i ≤ 15

is to be performed in the frequency domain with an n-point DFT. What is the minimum value of n that
produces the expected triangular result.

(ans: The convolution of two 16-point sequences results in a sequence that has a duration equal to 31
points. Hence, the DFT must be computed over at least 31 points, or an n = 31 point DFT, with the
minimum k interval being 0 ≤ k ≤ 30. To form the 31-point DFTs the 16-point xi sequence must be
padded with 15 zeros.
)

© 2015 Cengage Learning. All Rights Reserved. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part.
112 CHAPTER 9. SPECTRAL ANALYSIS

9.2 Matlab Projects


Project 9.1 (Direct computation of DFT) Consider Example 16.42 to verify Examples 9.2 and 9.3 by
composing a Matlab script to compute the DFT and plot the magnitude |Xk |. Evaluate the DFT using
the direct computation given by either Eq. (9.1) or Eq (9.4) for

x0 = 1, x1 = 1, and xi = 0 for 2 ≤ i ≤ 63

and plot |Xk | for 0 ≤ k ≤ 63.

(ans: Using Eq.(9.1)


x −1
n∑
Xk = xi e−jωk i for 0 ≤ k ≤ nx − 1
i=0
clear
nx = 64;
x = [1 1 zeros(1,nx-2)]; % define nx-element array
kf = 0:nx-1; % define k (frequency) index
for k = 1:nx % k starts at 1 to accommodate Matlab indexing
s = 0; % initialize sum
for i = 1:nx
omega = 2*pi*(k-1)*(i-1)/nx; % NOTE (k-1) & (i-1)
s = s + x(i)*exp(-j*omega);
end
Xmag(k) = abs(s);
end
stem(kf, Xmag) % NOTE kf starts at 0 to start omega_i at 0
xlabel(’k’); ylabel(’|X(k)|’)
axis([0 max(kf) 1.1*min(Xmag) 1.1*max(Xmag)])

2.2

1.8

1.6

1.4

1.2
|X(k)|

0.8

0.6

0.4

0.2

0 10 20 30 40 50 60
k

Using Eq.(9.4) produces the same figure


x −1
n∑ x −1
n∑
Xk = xi cos(ωk i) − j xi sin(ωk i) for 0 ≤ k ≤ nx − 1
i=0 i=0

Same script as above but with modification


s = s + x(i)*exp(-j*omega);
replaced by
s = s + x(i)*cos(omega) - j*x(i)*sin(omega);

© 2015 Cengage Learning. All Rights Reserved. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part.
9.2. MATLAB PROJECTS 113

Project 9.2 (Non-conventional DFT) Conventional DFT algorithms transform nx time points into nx
frequency points of which only the points 0 ≤ k ≤ nx /2 are ”actual.” To show that the direct compu-
tation of the DFT given by either Eq. (9.1) or Eq. (9.4) can be done for only the ”actual” frequencies,
compute |Xk | for 0 ≤ k ≤ nx /2 for the time sequence given by

x0 = 1, x1 = 1, and xi = 0 for 2 ≤ i ≤ 63

and plot |Xk | for 0 ≤ k ≤ 32.

(ans: Using Eq.(9.1)


x −1
n∑
Xk = xi e−jωk i for 0 ≤ k ≤ nx /2
i=0

clear
nx = 64;
x = [1 1 zeros(1,nx-2)]; % define nx-element array
kf = 0:nx/2; % define k (frequency) index
for k = 1:nx/2+1 % k starts at 1 to accommodate Matlab indexing
s = 0; % initialize sum
for i = 1:nx
omega = 2*pi*(k-1)*(i-1)/nx; % NOTE (k-1) & (i-1)
s = s + x(i)*exp(-j*omega);
end
Xmag(k) = abs(s);
end
stem(kf, Xmag) % NOTE kf starts at 0 to start omega_i at 0
xlabel(’k’); ylabel(’|X(k)|’)
axis([0 max(kf) 1.1*min(Xmag) 1.1*max(Xmag)])

2.2

1.8

1.6

1.4

1.2
|X(k)|

0.8

0.6

0.4

0.2

0 5 10 15 20 25 30
k

Using Eq.(9.4) produces the same figure


x −1
n∑ x −1
n∑
Xk = xi cos(ωk i) − j xi sin(ωk i) for 0 ≤ k ≤ nx − 1
i=0 i=0

Same script as above, but with modification


s = s + x(i)*exp(-j*omega);
replaced by
s = s + x(i)*cos(omega) - j*x(i)*sin(omega);

© 2015 Cengage Learning. All Rights Reserved. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part.
114 CHAPTER 9. SPECTRAL ANALYSIS

Project 9.3 (Verifying Matlab’s FFT algorithm) Verify Matlab’s FFT function for
x0 = 1, x1 = 1, and xi = 0 for 2 ≤ i ≤ 63
by computing and plotting |Xk | for 0 ≤ k ≤ 63 and comparing to the results obtained in Project 9.1.
(ans:
clear
nx = 64;
x = [1 1 zeros(1,nx-2)]; % define nx-element array
kf = 0:nx-1; % define k (frequency) index
Xmag = abs(fft(x)); % fft algorithm
stem(kf, Xmag) % NOTE kf starts at 0 to start omega_i at 0
xlabel(’k’); ylabel(’|X(k)|’)
axis([0 max(kf) 1.1*min(Xmag) 1.1*max(Xmag)])

1.5
|X(k)|

0.5

0
0 10 20 30 40 50 60
k

Project 9.4 (Non-power of 2 nx -point FFT) Verify that nx need not be a power of 2 by computing the
100-point FFT for
x0 = 0.5, x1 = 1, x2 = 0.5, and xi = 0 for 3 ≤ i ≤ 99
and extract the actual frequencies by plotting |Xk | for 0 ≤ k ≤ 50,
(ans:
clear
nx = 100;
x = [0.5 1 0.5 zeros(1,nx-3)]; % define nx-element array
kf = 0:nx/2; % define k (frequency) index
Xmag = abs(fft(x)); % fft algorithm
stem(kf, Xmag(1:nx/2+1)) % NOTE kf starts at 0 to start omega_i at 0
xlabel(’k’); ylabel(’|X(k)|’)
axis([0 max(kf) 1.1*min(Xmag) 1.1*max(Xmag)])

1.5
|X(k)|

0.5

0
0 5 10 15 20 25 30 35 40 45 50
k

© 2015 Cengage Learning. All Rights Reserved. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part.
9.2. MATLAB PROJECTS 115

Project 9.5 (Magnitude and phase of the 3-sample averager) Let


1
yi = (xi + xi−1 + xi−2 )
3
and hi be its unit-sample response.

hpi = hi for 0 ≤ i ≤ nh − 1
= 0 for nh ≤ i ≤ nf − 1 (nf = 80)

Use subplot(3,1,n),stem(.) to plot hpi , |Hpk |, and ∠Hpk for 0 ≤ k ≤ nf /2.


(ans:
clear
nf = 80;
h = [1/3 1/3 1/3 zeros(1,nf-3)]; % define nf-element array
i = 0:nf-1; % define time index
subplot(3,1,1),stem(i(1:11), h(1:11)) % NOTE i starts at
xlabel(’i’); ylabel(’h_i’)
axis([0 10 1.1*min(h) 1.1*max(h)])
kf = 0:nf/2; % define k (frequency) index
H = fft(h); % fft algorithm
Hmag = abs(H); % magnitide
subplot(3,1,2),stem(kf, Hmag(1:nf/2+1)) % NOTE kf starts at 0 to start omega_i at 0
xlabel(’k’); ylabel(’|H_k|’)
axis([0 max(kf) 1.1*min(Hmag) 1.1*max(Hmag)])
Hphase = atan2(imag(H),real(H)); % phase
subplot(3,1,3),stem(kf, Hphase(1:nf/2+1))
xlabel(’k’); ylabel(’\angle H_k’)
axis([0 max(kf) -pi pi])

0.3

0.2
i
h

0.1

0
0 1 2 3 4 5 6 7 8 9 10
i

1
0.8
|H |

0.6
k

0.4
0.2

0 5 10 15 20 25 30 35 40
k

2
∠ Hk

−2

0 5 10 15 20 25 30 35 40
k

© 2015 Cengage Learning. All Rights Reserved. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part.
116 CHAPTER 9. SPECTRAL ANALYSIS

Project 9.6 (Magnitude response of the 3-sample interpolator) The zero-padded unit-sample response
of a 3-sample MA digital filter that acts as linear interpolator is given by

h0 = 0.5, h1 = 1, h2 = 0.5, and hi = 0 for 3 ≤ i ≤ 63

Compute and plot the magnitude response |Hk | for 0 ≤ k ≤ 63.


(ans:
clear
nf = 64;
h = [0.5 1 0.5 zeros(1,nf-3)]; % define nf-element array
i = 0:nf-1; % define time index
subplot(2,1,1),stem(i,h) % NOTE i starts at
xlabel(’i’); ylabel(’h_i’)
axis([0 10 1.1*min(h) 1.1*max(h)])
kf = 0:nf-1; % define k (frequency) index
H = fft(h); % fft algorithm
Hmag = abs(H); % magnitide
subplot(2,1,2),stem(kf, Hmag) % NOTE kf starts at 0 to start omega_i at 0
xlabel(’k’); ylabel(’|H_k|’)
axis([0 max(kf) 0 1.1*max(Hmag)])

0.8

0.6
i
h

0.4

0.2

0
0 1 2 3 4 5 6 7 8 9 10
i

1.5
|H |
k

0.5

0
0 10 20 30 40 50 60
k

© 2015 Cengage Learning. All Rights Reserved. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part.
9.2. MATLAB PROJECTS 117

Project 9.7 (Padding with zeros) Compute the convolution of two rectangular sequences, each defined
by
xi = 1 for 0 ≤ i ≤ 15
in the frequency domain with n-point DFTs using the minimum value of n that produces the expected
results.
(ans:
clear
nx = 16;
x= ones(1,nx); % define x_i
ny = 2*nx-1; % compute duration of y_i
xp = [x zeros(1,nx-1)]; % pad x with zeros
i = 0:length(xp)-1;
subplot(2,1,1),stem(i,xp) % NOTE i starts at
xlabel(’i’); ylabel(’xp_i’)
axis([0 max(i) 0 1.1])
X1 = fft(xp); % DFT of xp
X2 = fft(xp); % DFT of other xp
Y = X1 .* X2; % Y_k
y = ifft(Y); % inverse DFT
subplot(2,1,2),stem(i,y) % NOTE kf starts at 0 to start omega_i at 0
xlabel(’i’); ylabel(’y_i’)
axis([0 max(i) 0 1.1*max(y)])

0.8

0.6
i
xp

0.4

0.2

0
0 5 10 15 20 25 30
i

15

10
yi

0
0 5 10 15 20 25 30
i

© 2015 Cengage Learning. All Rights Reserved. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part.
118 CHAPTER 9. SPECTRAL ANALYSIS

Project 9.8 (Signal processing in the frequency domain) Extend Example 16.46 to compose Matlab
code that performs digital filter operations in the frequency domain of a MA digital filter that computes
the running average of three input samples, using the following steps:
1. Formulate the filter transfer function Hk for k = 0, 1, 2, . . . , nx − 1(nx = 20).
2. Using the input command, enter xi array containing fewer than nx values. (See Example 16.47).
3. Pad xi with zeros to form xpi for i = 0, 1, 2, . . . , nx − 1.
4. Compute Xk for k = 0, 1, 2, . . . , nx − 1.
5. Compute Yk = Hk Xk for k = 0, 1, 2, . . . , nx − 1.
6. Compute and plot yi for i = 0, 1, 2, . . . , nx − 1 from the inverse DFT of Yk .
(ans:
clear
nx = 20;
i = 0:nx-1;
h = [1 1 1 zeros(1,nx-3)]; % pad h with zeros
subplot(3,1,1),stem(i,h) % NOTE kf starts at 0 to start omega_i at 0
xlabel(’i’); ylabel(’h_i’)
axis([0 max(i) 0 1.1*max(h)])
H = fft(h); % DFT of h
str =[’input <’ num2str(nx-2) ’ x array values within brackets ’];
x= input(str); % define x_i
xp= [x zeros(1,nx-length(x))]; % pad x with zeros
subplot(3,1,2),stem(i,xp) % NOTE kf starts at 0 to start omega_i at 0
xlabel(’i’); ylabel(’xp_i’)
axis([0 max(i) 1.1*min(xp) 1.1*max(xp)])
X = fft(xp); % DFT of xp
Y = H .* X; % Y_k
y = ifft(Y); % inverse DFT
subplot(3,1,3),stem(i,y) % NOTE kf starts at 0 to start omega_i at 0
xlabel(’i’); ylabel(’y_i’)
axis([0 max(i) 0 1.1*max(y)])

1
hi

0.5

0
0 2 4 6 8 10 12 14 16 18
i

1
xpi

0.5

0
0 2 4 6 8 10 12 14 16 18
i

2
i
y

0
0 2 4 6 8 10 12 14 16 18
i

© 2015 Cengage Learning. All Rights Reserved. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part.

You might also like