10.2 Discrete-Time Fourier Transform 577
so thatx[n]=A+0.5Bcos((ω 0 +ω 1 )n)+0.5Bcos((ω 1 −ω 0 )n). Lettingω 2 =ω 0 +ω 1 andω 3 =
ω 1 −ω 0 , the DTFT ofx[n] is
X(ejω)= 2 πA+πB(δ(ω−ω 2 )+δ(ω+ω 2 ))+πB(δ(ω−ω 3 )+δ(ω+ω 3 ))
Comparing this DTFT with the given one, we find that
2 πA= 1 ⇒A= 1 /( 2 π)
ω 2 =ω 0 +ω 1 = 4
ω 3 =ω 1 −ω 0 = 2
πB=1, 0.5⇒ no unique value for B
Although we find thatA= 1 /( 2 π)andω 0 =1 andω 1 =3, there is no unique value forB, so the
givenx[n] is not the correct answer. The correct signal should bex[n]=( 1 /π)(0.5+cos( 4 n))+
( 1 / 2 π)cos( 2 n), which has the desired DTFT (verify it!). n
10.2.3 Computation of the DTFT Using MATLAB
According to the definitions of the direct and the inverse DTFT, their computation needs to be done
for a continuous frequencyω∈[−π,π)and requires integration. In MATLAB the DTFT is approxi-
mated in a discrete set of frequency values, and summation instead of integration is used. As we will
see later, this can be done by sampling in frequency the DTFT to obtain the discrete Fourier transform
(DFT), which in turn is efficiently implemented by an algorithm called the Fast Fourier Transform
(FFT). We will introduce the FFT in Chapter 12, and so for now consider the FFT as a black box
capable of giving a discrete approximation of the DTFT.
To understand the use of the MATLAB functionfftin the script below consider the following issues:
n The commandX = fft(x), wherexis a vector with the entries the sample valuesx[n],n=0,...,L−1,
computes the FFT valuesX[k],k=0,...,L−1, or the DTFTX(ejω)at discrete frequencies{ 2 πk/L}.
n The{k}values correspond to the discretized frequencies{ωk= 2 πk/L}, which go from 0 to 2π(L−
1 )/L(close to 2πfor largeL). This is a discretization of the frequencyω∈[0, 2π).
n To find an equivalent representation of the frequencyω∈[−π,π), we simply subtractπfrom
ωk= 2 πk/Lto get a band of frequencies,
ω ̃k=ωk−π=π
2 k−L
L
,k=0,...,L−1 or −π≤ ̃ωk< π
The frequencyω ̃can be normalized to [−1, 1)with no units by dividing byπ. This change in
the frequency scale requires a corresponding shift of the magnitude and the phase spectra. This is
done by means of the MATLAB functionfftshift.
n When plotting the signal, which is discrete in time, the functionstemis more appropriate than
plot. However, theplotfunction is more appropriate for plotting the magnitude and the phase
frequency response functions, which are supposed to be continuously varying with respect to
frequency.