THE DISCRETE FOURIER SERIES
5.1 THE DISCRETE FOURIER SERIES
In Chapter 2 we defined the periodic sequence by ˜ x(n), satisfying the condition
(5.1) where N is the fundamental period of the sequence. From Fourier analysis
x(n) = ˜ ˜ x(n + kN ), ∀n, k
we know that the periodic functions can be synthesized as a linear com- bination of complex exponentials whose frequencies are multiples (or har- monics) of the fundamental frequency (which in our case is 2π/N ). From the frequency-domain periodicity of the discrete-time Fourier transform, we conclude that there are a finite number of harmonics; the frequencies are { 2π N k, k = 0, 1, . . . , N − 1}. Therefore a periodic sequence ˜ x(n) can
be expressed as
1 N −1 !
x(n) = ˜
X(k)e ˜ j 2π N kn , n = 0, ±1, . . . , (5.2)
N k=0
where { ˜ X(k), k = 0, ±1, . . . , } are called the discrete Fourier series co- efficients, which are given by
N −1 ! X(k) = 2π ˜ ˜ x(n)e −j N nk , k = 0, ±1, . . . ,
n=0
Note that ˜ X(k) is itself a (complex-valued) periodic sequence with fun- damental period equal to N , that is,
(5.4) The pair of equations (5.3) and (5.2), taken together, is called the discrete △
X(k + N ) = ˜ ˜ X(k)
Fourier series representation of periodic sequences. Using W N =e −j 2π N to
The Discrete Fourier Series 143
denote the complex exponential term, we express (5.3) and (5.2) as
X(k) ˜ △
N −1 "
= DFS[˜ x(n)] =
x(n)W ˜ nk N
: Analysis or a
n=0
DFS equation
1 N −1 "
x(n) ˜ = IDFS[ ˜ X(k)] =
X(k)W ˜ −nk
: Synthesis or an inverse
k=0
DFS equation (5.5)
EXAMPLE 5.1
Find DFS representation of the periodic sequence
x(n) = {. . . , 0, 1, 2, 3, 0 ˜ , 1, 2, 3, 0, 1, 2, 3, . . .}
Solution The fundamental period of this sequence is N = 4. Hence W 4 =e − j 2π 4 =
− j. Now ! 3
X(k) = ˜
x(n)W ˜ nk 4 , k = 0, ±1, ±2, . . .
x(n)W ˜ 0·n 4 =
˜ x(n) = ˜ x(0) + ˜ x(1) + ˜ x(2) + ˜ x(3) = 6
Similarly, ! 3 ! 3
X(1) = ˜
x(n)W ˜ n 4 =
x(n)(−j) ˜ n = (−2 + 2j)
X(2) = ˜ !
x(n)W ˜ 2n 4 =
x(n)(−j) ˜ 2n =2
X(3) = ! x(n)W ˜
3n
x(n)(−j) ˜ 3n = (−2 − 2j)
5.1.1 MATLAB IMPLEMENTATION
A careful look at (5.5) reveals that the DFS is a numerically computable representation. It can be implemented in many ways. To compute each sample ˜ X(k), we can implement the summation as a for...end loop. To compute all DFS coefficients would require another for...end loop. This will result in a nested two for...end loop implementation. This is clearly inefficient in MATLAB. An efficient implementation in MATLAB
Chapter 5
THE DISCRETE FOURIER TRANSFORM
would be to use a matrix-vector multiplication for each of the relations in (5.5). We have used this approach earlier in implementing a numerical
approximation to the discrete-time Fourier transform. Let ˜ x and ˜ X denote column vectors corresponding to the primary periods of sequences ˜ x(n) and ˜ X(k), respectively. Then (5.5) is given by
X ˜ =W N ˜ x
where the matrix W N is given by
n −→
···W N
1 (N −1)
kn
N 0≤k,n≤N−1
···W N
(N −1) 2
The matrix W N is a square matrix and is called a DFS matrix. The following MATLAB function dfs implements this procedure.
function [Xk] = dfs(xn,N) % Computes Discrete Fourier Series Coefficients % --------------------------------------------- % [Xk] = dfs(xn,N) % Xk = DFS coeff. array over 0 <= k <= N-1 % xn = One period of periodic signal over 0 <= n <= N-1 % N = Fundamental period of xn % n = [0:1:N-1];
% row vector for n
k = [0:1:N-1];
% row vecor for k
WN = exp(-j*2*pi/N);
% Wn factor
nk = n’*k;
% creates a N by N matrix of nk values
WNnk = WN .^ nk;
% DFS matrix
Xk = xn * WNnk;
% row vector for DFS coefficients
The DFS in Example 5.1 can be computed using MATLAB as
>> xn = [0,1,2,3]; N = 4; Xk = dfs(xn,N) Xk =
6.0000 -2.0000 + 2.0000i -2.0000 - 0.0000i -2.0000 - 2.0000i
The Discrete Fourier Series 145
The following idfs function implements the synthesis equation.
function [xn] = idfs(Xk,N) % Computes Inverse Discrete Fourier Series % ---------------------------------------- % [xn] = idfs(Xk,N) % xn = One period of periodic signal over 0 <= n <= N-1 % Xk = DFS coeff. array over 0 <= k <= N-1 % N = Fundamental period of Xk % n = [0:1:N-1];
% row vector for n
k = [0:1:N-1];
% row vecor for k
WN = exp(-j*2*pi/N);
% Wn factor
nk = n’*k;
% creates a N by N matrix of nk values
WNnk = WN .^ (-nk);
% IDFS matrix
xn = (Xk * WNnk)/N;
% row vector for IDFS values
Caution: These functions are efficient approaches of implementing (5.5) in MATLAB. They are not computationally efficient, especially for large N . We will deal with this problem later in this chapter.
EXAMPLE 5.2
A periodic “square wave” sequence is given by
mN ≤ n ≤ mN + L − 1
˜ x(n) =
; m = 0, ±1, ±2, . . .
0, mN + L ≤ n ≤ (m + 1) N − 1
where N is the fundamental period and L/N is the duty cycle.
a. Determine an expression for | ˜ X(k)| in terms of L and N . b. Plot the magnitude | ˜ X(k)| for L = 5, N = 20; L = 5, N = 40; L = 5, N = 60; and L = 7, N = 60. c. Comment on the results.
Solution A plot of this sequence for L = 5 and N = 20 is shown in Figure 5.1.
Three Periods of xtilde(n) 1.5
n FIGURE 5.1 Periodic square wave sequence
Chapter 5
THE DISCRETE FOURIER TRANSFORM
a. By applying the analysis equation (5.3),
X(k) = ˜
˜ x(n)e − j 2π N nk
k = 0, ±N, ±2N, . . .
⎩ 1−e
− j2πLk/N
, otherwise
1−e − j2πk/N
The last step follows from the sum of the geometric terms formula (2.7) in Chapter 2. The last expression can be simplified to
1−e − j2πLk/N
e − jπLk/N e jπLk/N − e − jπLk/N
1−e − j2πk/N
e − jπk/N e jπk/N − e − jπk/N
=e − jπ(L−1)k/N sin (πkL/N ) sin (πk/N )
or the magnitude of ˜ X(k) is given by
L,
k = 0, ±N, ±2N, . . .
1 X(k) ˜ 1 ⎨
1 sin (πkL/N ) ⎩ 1 ⎪ 1
1 sin (πk/N ) 1 , otherwise b. The MATLAB script for L = 5 and N = 20:
>> L = 5; N = 20; k = [-N/2:N/2];
% Sq wave parameters
>> xn = [ones(1,L), zeros(1,N-L)];
% Sq wave x(n)
>> Xk = dfs(xn,N);
% DFS
>> magXk = abs([Xk(N/2+1:N) Xk(1:N/2+1)]); % DFS magnitude >> subplot(2,2,1); stem(k,magXk); axis([-N/2,N/2,-0.5,5.5]) >> xlabel(’k’); ylabel(’Xtilde(k)’) >> title(’DFS of SQ. wave: L=5, N=20’)
The plots for this and all other cases are shown in Figure 5.2. Note that since ˜ X(k) is periodic, the plots are shown from −N/2 to N/2. c. Several interesting observations can be made from plots in Figure 5.2. The envelopes of the DFS coefficients of square waves look like “sinc” functions. The amplitude at k = 0 is equal to L, while the zeros of the functions are at multiples of N/L, which is the reciprocal of the duty cycle. We will study these functions later in this chapter.
5.1.2 RELATION TO THE z-TRANSFORM Let x(n) be a finite-duration sequence of duration N such that
3 Nonzero, 0 ≤ n ≤ N − 1
x(n) =
Elsewhere
The Discrete Fourier Series 147
DFS of Sq. wave: L=5, N=20
DFS of Sq. wave: L=5, N=40
|Xtilde(k)| 2 |Xtilde(k)| 2 1 1
DFS of Sq. wave: L=5, N=60
DFS of Sq. wave: L=7, N=60
4 3 4 |Xtilde(k)| 2 |Xtilde(k)| 2 1 0 0
FIGURE 5.2 The DFS plots of a periodic square wave for various L and N
Then we can compute its z-transform: N −1 !
X(z) =
x(n)z −n
n=0
Now we construct a periodic sequence ˜ x(n) by periodically repeating x(n) with period N , that is,
3 x(n), 0 ≤ n ≤ N − 1 ˜
x(n) =
The DFS of ˜ x(n) is given by
N −1 !
N −1
X(k) = ˜
x(n)e ˜ N nk =
−j 2π
# 2π $ −n
x(n) e j N k
Comparing it with (5.9), we have
(5.12) which means that the DFS ˜ X(k) represents N evenly spaced samples of
X(k) = X(z)| ˜ z=e j 2π N k
the z-transform X(z) around the unit circle.
Chapter 5
THE DISCRETE FOURIER TRANSFORM
5.1.3 RELATION TO THE DTFT Since x(n) in (5.8) is of finite duration of length N , it is also absolutely summable. Hence its DTFT exists and is given by
x(n)e −jωn
x(n)e ˜ −jωn (5.13)
n=0
n=0
Comparing (5.13) with (5.11), we have
X(k) = X(e ˜ jω 1 ) 1 ω = 2π N k
N Then the DFS X(k) = X(e jω k ) = X(e jkω 1 ), which means that the DFS is
obtained by evenly sampling the DTFT at ω 1 = 2π N intervals. From (5.12) and (5.14) we observe that the DFS representation gives us a sampling mechanism in the frequency domain that, in principle, is similar to sam-
pling in the time domain. The interval ω 1 = 2π N is the sampling interval in the frequency domain. It is also called the frequency resolution because it tells us how close the frequency samples (or measurements) are.
EXAMPLE 5.3
Let x(n) = {0 , 1, 2, 3}.
a. Compute its discrete-time Fourier transform X(e jω ).
b. Sample X(e jω ) at kω 1 = 2π 4 k, k = 0, 1, 2, 3 and show that it is equal to
X(k) in Example 5.1. ˜
Solution
The sequence x(n) is not periodic but is of finite duration.
a. The discrete-time Fourier transform is given by
X(e jω
x(n)e − jωn =e − jω + 2e − j2ω + 3e − j3ω
n=−∞
b. Sampling at kω 1 = 2π 4 k, k = 0, 1, 2, 3, we obtain X(e j0 )=1+2+3=6=˜ X(0)
X(e j2π/4 )=e − j2π/4 + 2e − j4π/4 + 3e − j6π/4 = −2 + 2j = ˜ X(1) X(e j4π/4 )=e − j4π/4 + 2e − j8π/4 + 3e − j12π/4 =2=˜ X(2) X(e j6π/4 )=e − j6π/4 + 2e − j12π/4 + 3e − j18π/4 = −2 − 2j = ˜ X(3)
as expected.
Sampling and Reconstruction in the z -Domain 149