Professional Documents
Culture Documents
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
∑
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
∑
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
(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
© 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
∑
63
X0 = 0.9i
i=0
∑
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
∑
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
© 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
∑
63
X0 = (−0.9)i
i=0
∑
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
∑
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
(ans:
∞
∑ ∞ (
∑ )i
i −j2πki/nx
Hk = (−0.9) e = −0.9e−j2πk/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.
9.1. PROBLEMS 111
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
x0 = 1, x1 = 1, and xi = 0 for 2 ≤ i ≤ 63
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
© 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
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
© 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
hpi = hi for 0 ≤ i ≤ nh − 1
= 0 for nh ≤ i ≤ nf − 1 (nf = 80)
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
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.