Chap 11 TLH DFT
Chap 11 TLH DFT
TEX’d:
FOURIER
TRANSFORM AND
THE FFT
PREVIEW
507
techniques are ideally suited to studying the effects of sampling such
continuous functions.
This chapter introduces the Discrete Fourier transform (DFT) and an
important algorithm to compute the DFT, called the Fast Fourier transform
(FFT). Our emphasis is on the practical use of the FFT and the errors that
can arise from sampling a signal and then computing its DFT. The final
Section 11.6 explains the FFT algorithm.
One of the most important uses of Fourier analysis, although not the only
one by any means, is to analyze the frequency components of a signal
derived from measurements of a physical variable of interest. These sig-
nals can be functions that represent quantities changing with time, such
as voltage, force, or temperature. Light from a star can be analyzed to
determine the spectrum of the light from the star. Similarly, the Fourier
transform of radar echoes or audio (speech) signals is used to analyze the
characteristics of the source of the signals. The study of the frequency
content of such signals is called spectral analysis, and the Fourier trans-
form is the primary method to compute the spectrum analytically.
Before attempting to apply Fourier analysis by computer to physical
signals, it is necessary to thoroughly understand the frequency properties
of such signals. This is one area where the motto, “The purpose of com-
puting is insight, not numbers,” mentioned in the preface, must be taken
very seriously.1
First, suppose the physical signal of interest is a continuous func-
tion of time or another continuous variable. For computer analysis it is
necessary to represent the signal by a finite number of values of the sig-
nal, usually called samples of the signal. Second, the analytical form of
the Fourier methods, as presented in Chapter 8, assumes that the sig-
nal being analyzed is infinitely long in time. Obviously, any computer
representation of the signal must be finite in length. Thus, representing
a continuous signal for computer analysis leads to a finite-length vector
of sampled points with the possibility of various errors in representation.
Later in the chapter, we shall see that the spacing of the samples of a
time-dependent signal and the length of time of observation of the sig-
nal will determine the information that can be derived from frequency
analysis of the signal.
1
The motto is from Richard Hamming’s book, Numerical Methods for Scientists and Engineers.
1
Amplitude
0.5
0
−2 −1.5 −1 −0.5 0 0.5 1 1.5 2
t seconds
1.5
1
F(f)
0.5
−0.5
−2 −1.5 −1 −0.5 0 0.5 1 1.5 2
f hertz
From Equation 11.2, the zeros of the frequency spectrum occur at the points
d sin(2πf T/2)
AT = 0.
df (2πf T/2)
After dividing by the cosine term, the equation for the maxima is
T T
h i h i
tan 2πf = 2πf ,
2 2
which becomes x = tan x by substituting x = 2πf T/2. The solutions are tab-
ulated in the Handbook of Mathematical Functions by Abramowitz and Stegun
listed in the Annotated Bibliography for this chapter. For a pulse with ampli-
tude A = 1 and width T = 1 second, Table 11.1 shows the first four frequencies
at which there are relative maxima of the magnitude of the spectrum. The
values at these points show that the magnitudes of the frequency components
diminish rapidly with increasing frequency. For practical purposes, the spec-
trum can be assumed to be zero above some frequency.
f hertz |F (f )|
0.0000 1.0000
1.4303 0.2172
2.4590 0.1284
3.4709 0.0913
The ideal pulses just discussed cannot exist in nature since every physical
pulse has a finite rise time. The rise time is usually defined as the time for a
1
Amplitude
0.5
0
−2 −1.5 −1 −0.5 0 0.5 1 1.5 2
t seconds
1.5
1
F(f)
0.5
−0.5
−2 −1.5 −1 −0.5 0 0.5 1 1.5 2
f hertz
For the triangular pulse, the time taken for the signal to change from 0
to A is T/2 seconds, and the slope of the rising edge of the triangular pulse is
dPT /dt = 2A/T . Rewriting Equation 11.4 as
sin2 (2πf T/4)
2A
F (f ) =
T (πf )2
shows that the magnitude of the frequency components is proportional to the
slope of the rising edge of the signal. In the case of typical pulses used in
modern electronic equipment, the signal could change from 0 to 5 volts in 10
Both the DFT and FFT deal with discrete functions in time and
frequency. Thus, the DFT and the FFT transform a discrete sequence of
values fn , n = 0, . . . , N − 1, into another discrete sequence of values
Fk , k = 0, . . . , N − 1.
In this section, we discuss the DFT and FFT in order to interpret the
meaning of the Fk for practical signal processing.
f(t) f(nT s)
t
0
T
∆t = = Ts
N
T = NT s
f (t) Fr (f ) and Fi (f )
In this chapter, we consider only functions f(t) that are real functions
of time.
Frequency Range The DFT frequencies described by Equation 11.5
appear to range from f = 0 to f = (N − 1)fs . However, this is not
correct because of the symmetry of the transform results. Summarizing
the relationship between sampling in time and the frequency components
in the spectrum leads to the following conclusions:
1. The sample spacing in time Ts determines the highest positive
frequency in the DFT as
1
Fmax = ;
2Ts
–T T t 0 2π ω
–– –– ––
2 2 T
Periodic function Fourier Series
Discrete Spectrum
(a) Fourier series
f(t) F(ω)
Continuous f(t) t ω
Fourier Transform
Continuous Spectrum
(b) Fourier transform
N t N ω
Discrete f(ti) Discrete Periodic
Spectrum (DFT)
(c) Discrete Fourier transform
FIGURE 11.4 Comparison of Fourier techniques
FAST FOURIER There are many algorithms that are generally called fast Fourier transform
TRANSFORM algorithms. In fact, developing techniques to improve the efficiency of
(FFT) calculation for the Fourier transform has been an active research area for
many years. The algorithm is discussed in more detail in Section 11.6.
using the notation of Equation 11.7. In the upper plot, the DFT com-
ponents are plotted for the index k = 0 to k = N − 1 which emphasizes
the symmetry about the index value k = N/2. The k-th positive digital
frequency has the value F = k/N . The digital frequency, described in
Section 10.9, corresponding to Fmax is F = 1/2.
|FFT|
Positive Negative
Frequencies Frequencies
0 Fmax Frequency 0
012 ... N/2 Harmonic N
Negative Positive
frequencies frequencies
–fs 0 fs Fmax
0 Harmonic N/2
FIGURE 11.5 Discrete Fourier transform spectrum
Parameter Notation
Time domain:
Sample interval Ts (s)
Sample size N points
Length (N − 1)Ts (s)
Period (from IDFT) T = N Ts (s)
Frequency domain:
1 1
Frequency Spacing fs = = (Hz)
T N Ts
Spectrum size N components
N
Maximum frequency fs = Fmax (Hz)
2
1
Frequency period F p = N fs = (Hz)
Ts
The two important parameters in the time domain are the sampling
interval Ts and the number of sample points N since other parameters can
be derived in terms of these. Be careful to not confuse the period of the
reconstructed signal from the IDFT, T = N Ts , with the total sampling
time for the actual time signal. Also, the maximum frequency in the
spectrum is (N/2)fs = 1/(2Ts ) hertz, but the spectrum is periodic with
period N fs = Fp hertz.
DFT frequency in hertz In the frequency domain, the spectral lines
of the DFT are spaced a distance fs hertz or ωs = 2πfs radians/second
Command Result
abs Magnitude of FFT
angle Phase angle of FFT in radians (−π to π)
fft FFT
fftshift Moves zero frequency to center of spectrum
ifft Inverse FFT
nextpow2 Returns next power of 2
unwrap Unwraps phase angle beyond −π to π
stem Plots discrete sequence data
fourier Symbolic Fourier transform
The MATLAB commands fft and ifft compute the DFT and inverse
DFT, respectively, without regard for the actual sample spacing. The
input to the functions is a given number of samples of the time function
for fft or frequency function for ifft. Thus, the discrete functions that
result from MATLAB Fourier computations functions must be scaled if
an answer in physical units, such as hertz, is desired.
The result of fft is generally an array of complex numbers. The com-
mands abs and angle can be used to compute the magnitude and angle
INDEXING AND MATLAB vectors are indexed from 1 to N , where N is the number of ele-
TRANSPOSE ments. However, the standard definition of the DFT, as in Equation 11.5,
is indexed from 0 to N −1. Care must be taken in indexing when analyzing
and plotting the results of MATLAB FFT calculations.
If the MATLAB transpose operator (’) is used on a complex vector,
the operation gives the complex conjugate transpose; that is, the sign of
the imaginary part is changed as part of the transpose operation. This is
not generally desired if the transpose of the DFT results are to be used
since the sign of the phase angle would be changed. The operator (.’)
transposes a complex array but does not conjugate it.
MATLAB Script
Example 11.2
function [FT,FTmag,FTang] = clfftf(ft,N,Ts)
% CALL: [FT,FTmag,FTang] = clfftf(ft,N,Ts) Compute the DFT
% approximation of the Fourier Transform
% Inputs:
% ft Sampled function of time f(nTs)
% N Number of sample points
% Ts Sample interval in seconds
% Outputs:
% FT Approximate Fourier transform using DFT
% FTmag Magnitude of spectrum
% FTang Phase in degrees
% Determine the two-sided spectrum
FT1=Ts*(fft(ft,N)); % Scale to approximate FT
FT=fftshift(FT1); % Shift 0 to center
%
% Compute the magnitude and phase for the frequency values
% in hertz fs=1/(N*Ts); fmax=1/(2*Ts)
%
FTmag=abs(FT); % Magnitude
FTang=(180/pi)*angle(FT); % Phase in degrees
DFT OF THE The decaying exponential function is a good test function to use for ex-
EXPONENTIAL ploring the accuracy and problems of the DFT applied to a continuous
FUNCTION function.
0.8
0.6
0.4
0.2
0
−4 −3 −2 −1 0 1 2 3 4
Frequency in hertz
100
FT
DFT
Phase FT and DFT
50
−50
−100
−4 −3 −2 −1 0 1 2 3 4
Frequency in hertz
−t
FIGURE 11.6 Magnitude and phase of spectrum of e
Bandlimited
analog signal
f(t) Anti-Aliasing
Filter ADC Processor
nTs Sampled
|F( f )| data signal DFT
1
Ts < ––
2B
0 B Hz
fs > 2B
SAMPLING Two of the most important questions in the specification of a data acqui-
sition system such as that shown in Figure 11.7 are the following:
The DFT analysis yields the spectrum of Figure 11.8, with a maximum fre-
quency of 64 hertz and a resolution of 2 hertz. From the DFT analysis, the
spectrum appears to have a strong component at 20 hertz. In fact, the MAT-
LAB function that generated the signal was
>> N=128;
>> Ts=1/128;
>> t=0:Ts:Ts*(N-1);
>> ft=sin(2*pi*20*t);
>> ft=ft+randn(size(t));
>> save clex115.mat
where the MATLAB function randn generates random values (noise) superim-
posed on the sine wave. The MATLAB script analyzes the signal and plots the
result.
Signal
4
2
f(t)
−2
−4
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
Time in seconds
0.8
0.6
Spectrum
0.4
0.2
0
−80 −60 −40 −20 0 20 40 60 80
Frequency in hertz
MATLAB Script
Example 11.5
% EX11_5.M Compute the spectrum of a signal saved
% in file CLEX95.MAT. The data are:
% N samples of the |FFT| are plotted
% Ts sampling interval in seconds
% t time points
ALIASING If a signal is sampled at a rate that is equal to or less than the Nyquist
ERROR rate defined by the sampling theorem, aliasing errors can occur. The
name implies that one signal can be “impersonated” by another signal.
The impersonation caused by too-coarse sampling (undersampling) de-
scribes high-frequency components of the true spectrum appearing as
low-frequency components in the DFT spectrum.
The effect can be seen in several practical situations. Spoked wagon
wheels on a stagecoach going forward occasionally appear to rotate back-
ward when western films are shown on TV because the image of the
rotating wheel is being sampled. The continuous motion is represented
by a series of pictures (samples) taken at a time interval that is too slow
to capture the true motion of the wheel. The effect can also be seen when
a stroboscope is used to capture the motion of rotating equipment. If the
which should be sampled at a rate greater than 2f samples per second. Suppose
we sample at a rate corresponding to one-half the Nyquist frequency, or only f
samples per second. The sampling interval is thus Ts = 1/f , and the times of
sampling are
1 2 N −1
0, , , . . . , seconds
f f f
if N points are taken. Notice that f (nTs ) = cos(2πf nTs ) = 1 for every point
0 ≤ n < N . Now consider the constant function f (t) = 1 sampled at the same
rate. Both the cosine and the constant yield the time series
so we conclude that the cosine sampled at one-half of the Nyquist rate imper-
sonates a constant or dc value. The DFT of the cosine signal would indicate a
spectral value at f = 0 but not at the frequency of the cosine, since the maxi-
mum frequency in the DFT spectrum is f /2. The only solution to eliminate the
aliasing error is to sample at a rate that satisfies the sampling theorem. In prac-
tice, if the high-frequency components of the signal diminish rapidly, the effect
of aliasing may not be significant. The anti-aliasing filter in Figure 11.7 ensures
that the signal will be bandlimited in a practical data acquisition system.
LEAKAGE The IDFT produces an N -sample periodic time-series from the spectrum
ERROR created by the DFT. An error called leakage occurs when the actual signal
being sampled is not perfectly periodic over an N -sample interval. The
term implies that energy “leaks” from one frequency to another in the
DFT spectrum. Hence, the signal appears to have frequency components
that may not be present in the spectrum of the analog signal.
Truncating the time signal at t = (N − 1)Ts has the effect of intro-
ducing a discontinuity in the signal unless it is zero at the end point or
the signal is periodic with period T = N Ts . Increasing the DFT period
of the signal by increasing N tends to reduce the leakage effect unless the
analog signal is actually periodic. Problem 11.9 allows you to investigate
the effect.
SUMMARY OF Table 11.6 summarizes the major DFT errors that may arise from sam-
ERRORS pling at too low a rate or not sampling long enough. For the parameters
listed in the table, T = N Ts , so there are really only two parameters
to manipulate. Several problems at the end of this chapter are intended
to emphasize the effects on the DFT spectrum of changing the sampling
interval or the number of samples.
Condition Cure
Aliasing Increase maximum frequency
(decrease Ts )
Leakage Increase frequency resolution
(increase N )
Picket fence Increase frequency resolution
(increase N )
Using and interpreting the FFT results previously presented in this chap-
ter does not require a complete understanding of the algorithm itself since
the FFT is only one particular method of computing the discrete Fourier
transform (DFT). In this section, we only describe particular cases of the
FFT algorithm for simplicity. For example, we restrict the value of N
to an even number, and furthermore the discussion often assumes that
N = 2m for convenience in understanding and computation. References
in the Annotated Bibliography for this chapter treat other cases with a
more general FFT algorithm.
z N = a,
which is the formula for the N th root of a. The solution uses the theorem
of De Moivre
(cos θ + i sin θ)N = cos N θ + i sin N θ, (11.14)
which follows from the formula for multiplication of complex numbers
written in polar form as presented in Chapter 2. Writing a in polar
coordinates as a = r(cos θ + i sin θ), the roots of a are
√
1/N N
θ 2π θ 2π
a = r cos +p + i sin +p , (11.15)
N N N N
√
where p takes the values 0, 1, . . ., n − 1. The term N r is the positive real
N th root of r, and for the specific case |a| = 1, this value is 1.
Consider the values p/N for integers p = 0, 1, 2, 3 with N = 4. Writing
W4p = e−θ , where θ = 2πp/4, these values correspond to the angles
because n is an integer.
When f(t) is real, we expect that the real part of Fk is even and
the imaginary part is odd, using k = N/2 as the origin. Remember from
the previous discussions that the frequencies for k > N/2 are actually
negative frequencies so that
F̄k = FN−k
when f(t) is real and N is an even number, where F̄k is the complex conju-
gate of the term Fk . We say that the terms in the DFT exhibit conjugate
symmetry about the point N/2 in this case. Thus, computation can be
simplified if the DFT is to be computed directly from the definition.
F0 = 1+1 = 2
F1 = 1 + exp(−iπ/4) = 1.7071 − 0.7071i
F2 = 1 + exp(−iπ/2) = 1−i
F3 = 1 + exp(−iπ3/4) = 0.2929 − 0.7071i
F4 = 1 + exp(−iπ) = 0
F5 = 1 + exp(−iπ5/4) = 0.2929 + 0.7071i
F6 = 1 + exp(−iπ3/2) = 1+i
F7 = 1 + exp(−iπ7/4) = 1.7071 + 0.7071i.
WHAT IF? Compare the result of Example 11.7 with the results of
the MATLAB script
>>ft=[1,1,0,0,0,0,0,0]
>> Fw=fft(ft)
using the result of Equation 11.16. In Equation 11.20, the terms W45 =
W41 , W47 = W43 , and W49 = (W43 )3 = W41 .
Rewriting Equation 11.20 in matrix terms, considering the results
defined in Equations 11.21, yields
F0 1 1 1 1 f0
F1 1 −i −1 i
f1 .
F2 = 1 −1 (11.22)
1 −1 f2
F3 1 i −1 −i f3
N -Point DFT Using the approach used for the four-point problem,
the DFT for N points can be written
1 1 1 ··· 1
F0 f0
1 2 N−1
F1 1 WN WN · · · WN
f1
2 4
2(N−1)
F2
= 1 WN WN · · · WN f2
.
.. .. .. .. .. .. ..
. . . . . . .
FN−1 N−1 2(N−1) (N−1)2 f
1 WN WN · · · WN N−1
(11.23)
The Fourier equation (11.23), which can be written as
F = WNnk f ,
(11.24)
F0 1 1 1 1 1 10
F1 1 −i −1 i 2 −2 + 2i
F = = . (11.25)
2 1 −1 1 −1 3 −2
F3 1 i −1 −i 4 −2 − 2i
Formulation of the DFT matrix from direct application of the DFT defi-
nition has a number of computational drawbacks. Obviously, it would not be
very efficient to store the N × N matrix if N is a large number. In any case, the
direct computation method is not considered computationally efficient, and it
is desirable to find methods of speeding up the computer calculation by reduc-
ing the number of operations. When comparing computational methods, only
the multiplications are usually counted since they are by far the most time-
consuming compared to the time for addition, subtraction, and retrieval and
storage of data values.
FFT As we have seen, the direct calculation of the N -point DFT requires
ALGORITHMS N 2 complex multiplications. A number of researchers have developed
algorithms called fast Fourier transform algorithms that more efficiently
compute the DFT. These algorithms essentially reduce the problem of
calculating an N -point DFT to that of calculating many DFTs for smaller
values of N . Although there are numerous algorithms, the algorithms
generally perform an efficient DFT by taking advantage of the following:
F0 = f0 + f1
F1 = f0 − f1 .
To factor the DFT for the FFT algorithm, the DFT is written in terms
of the even and odd indices of f (n). We assume that N = 2m and show the
case for N = 4 written in terms of two, two-point transforms. This algorithm
is described as a decomposition-in-time or decimation-in-time, radix-2 FFT.
The kth term in the four-point transform is
3
X
Fk = f (n)e−i2πnk/4
n=0
fen = f2n , n = 0, 1
fon = f2n+1 , n = 0, 1
so that
Fk = [fe0 + fe1 (−1)k ] + [fo0 + fo1 (−1)k ]W41k , (11.29)
where the factors in brackets are two-point DFTs. If we define
F0 = Fe0 + Fo0
F1 = Fe1 − Fo1 (i)
F2 = Fe0 − Fo0
F3 = Fe1 + Fo1 (i). (11.31)
In the final expression, the values W41k = (−i)k for each k were used.
The conclusion is that the four-point DFT can be written as follows
The result in Example 11.9 can be generalized for radix-2 FFT al-
gorithms to show that an N -sample DFT can be written as the sum of
two N/2-sample DFTs formed from the even- and odd-indexed samples
of the original sequence. When N = 2m , this process of decomposition
or decimation can be continued until the N -point FFT can be computed
by properly combining N/2 two-point transforms. The reader should see
the references in the Annotated Bibliography for this chapter for more
information about this important algorithm.
In these problems, do the computations by hand unless otherwise indicated and then check those
that yield numerical or symbolic results with MATLAB.
REINFORCEMENT EXERCISES
P11.1. Periodicity of the DFT Show that the DFT defined in Equation 11.5 is periodic.
Thus, for an arbitrary integer r,
r+N r
F =F .
N Ts N Ts
P11.2. Approximation to Fourier transform Consider the Fourier transform of a function
Z ∞
F (ω) = f (t)e−iωt dt
−∞
applied to a function sampled at intervals t = nTs . Assume that the function is defined only for
t > 0 and further that f (nTs ) is almost zero for n ≥ N when N is a sufficiently large number. By
Hint: Assume that the sampling interval is sufficiently small that exponentials not involving k
or n can be expanded in a Taylor series with only two terms.
P11.3. DFT conditions Determine the functions f (t) that have the properties that meet the
criteria for exact DFT representation:
Hint: Consider the answer in terms of the Fourier series expansion of the function.
P11.4. Direct calculation of DFT A good way to understand the DFT is to calculate the
DFT for a simple function by hand. Determine the DFT for the discrete function
1, 0 ≤ n ≤ 4,
fn =
0, 5 ≤ n ≤ 9.
Plot the amplitude and phase of the transform and describe the symmetries in the transform.
P11.5. Aliasing Given that the sampling rate is 10 samples per second for the following signals,
are they aliased?
a. f (t) = cos(2πt)
b. f (t) = cos(4πt)
c. f (t) = cos(10πt)
d. f (t) = cos(12πt)
e. f (t) = cos(14πt)
P11.6. MATLAB discrete signal Create a 256-point function with a 25% duty cycle of ones
(64 points) and compute the Fourier spectrum and plot it.
a. Try using the MATLAB command kron to create the discrete pulse.
b. Compute the maximum error when compared with the Fourier transform of a pulse.
P11.9. MATLAB FFT leakage Compare the FFT results for the functions:
f (t) = sin(2π20t) and g(t) = sin(2π19t)
by sampling 64 points with a time resolution of 1/128 second.
a. Plot the magnitude of each FFT on a subplot to compare the results.
b. Explain the extra frequency components in each result.
P11.10. DFT matrix Show that the inverse of the N × N Fourier matrix of Equation 11.23 is
the conjugate transpose divided by N . Therefore, the algorithm to compute the DFT can be used,
with minor modifications, to compute the inverse DFT.
P11.11. DFT 8-point matrix Work out the 8-point DFT matrix from Equation 11.23.
P11.12. Four-point FFT matrix Show that the four-point FFT as in Example 11.9 can be
written as the product of matrices as
F0 1 0 1 0 1 1 0 0 1 0 0 0 f0
F1 0 1 0 −i 1 −1 0 0 0 0 1 0 f1
F = 1 0 −1 0 0 0 1 1 0 1 0 0 f2
.
2
F3 0 1 0 i 0 0 1 −1 0 0 0 1 f3
Explain the meaning of each matrix.
EXPLORATION PROBLEMS
P11.16. MATLAB FFT phase Given the function
e−t , t ≥ 0,
f (t) =
0, t < 0,
as treated in Example 11.3, compute the phase of the function and compare the results with the
actual value. Use the MATLAB command fftshift to plot the two-sided spectrum from −Fmax to
Fmax, where the frequency range will be determined by the sampling interval of f (t) and the
number of points taken.
Hint: Try to approach the Fourier transform result (at least near the origin) by adding zeros to
increase the period of the time function as much as possible. This method is called zero padding to
lengthen the sequence of sampled points. However, zero padding does not add any information
about the signal being analyzed.
P11.17. MATLAB discrete spectrum plot Write an M-function to plot a discrete spectrum
versus frequency in hertz or radians per second. The function call should be:
function plotdscf(f,F,xunit)
% CALL: plotdscf(f,F,xunit); plot a discrete spectrum [f F]
% Inputs to function are
% f - frequencies
% F - spectral values
% xunit - units of frequency (Hz or rad/s)
P11.18. FFT Investigation (Optional) Consider the unit step function, U (t) = 1 for f > 0,
defined in Chapter 6. Its ordinary Fourier transform does not exist (because the signal would have
infinite energy) but a generalized transform can be defined. The transform is written
1
F [U (t)] = πδ(ω) + ,
iω
where δ(ω) is the unit impulse function. Attempt to compute the DFT of the unit step function
and explain the result. Use the inverse FFT (ifft) on the result and reconstruct the time function.
Compare the results with the Laplace transform of the unit step function.
P11.19. MATLAB DFT nk matrix Write a MATLAB script with N as input to compute the
N -point DFT matrix WN .
P11.20. MATLAB Script Write a MATLAB script that computes the DFT directly from the
definition with the inputs
Compare the FFT result with |F (ω)| and find the maximum error for various values of N , the
number of samples; N = 16, 128, 1024. For each value of N , plot |F (ω)| and the FFT result on the
same graph.
Remember you are comparing the Fourier transform of a time signal with the FFT results.
P11.22. MATLAB Script comparing DFT and FFT Write a MATLAB script to compare
the time of the DFT routine from the previous problem and the MATLAB FFT routine. The
result should be a table of the form
Comparison of DFT and FFT times
N DFT FFT FFT/DFT log2 N/N
8 Time1 etc.
64
128
1024
In the table, N is the number of sample points and the times are in seconds (or fractions of a
second). Test the functions:
a. f = {1 1 0 0 0 0 0 0 . . .}.
b. A random sequence of N numbers.
P11.23. MATLAB Script comparing Fourier transform and FFT Compute the Fourier
transform of the function
f (t) = e−t cos 100t.
Then, plot the following on the same figure:
11.9 ANSWERS
11.1 Periodicity of the DFT For an arbitrary integer r, the DFT component at index
k = r + N is
N −1
r+N
X
F = f (nTs )e−i2πn(r+N )/N .
N Ts
n=0
since
e−i2πn = cos 2πn − i sin 2πn = 1
W80 = 1
√
W81 = (1 − i)/ 2
W82 = −i
√
W83 = −(1 + i)/ 2
W84 = −1
√
W85 = −(1 − i)/ 2
W86 = i
√
W87 = (1 + i)/ 2.
Since W8nk = W8nk mod 8 , relationships such as W80 = W88 = W816 = W824 , etc., reduce the matrix to
the form
1 1 1 1 1 1 1 1
1 W81 W82 W83 W84 W85 W86 W87
1 W82 W84 W86 W80 W82 W84 W86
nk 1 W83 W86 W81 W84 W87 W82 W85
W8 = .
4 0 4 0 4
1 W8 W8 W8 W8 W8 W80 W84
1 W5 W2 W7 W4 W1 W86 W83
8 8 8 8 8
1 W6 W4 W2 W0 W6 W84 W82
6 8 8 8 8
1 W87 W86 W85 W84 W83 W82 W81
11.15 Four point FFT Verify your answer with the result of Example 11.8.