Docsity

Fourier Analysis-Signal Processing And Analysis-Handout, Exercises of Signal Processing and Analysis

Toggle sidebar
bg1
Chapter 8
Fourier Analysis
We all use Fourier analysis every day without even knowing it. Cell phones, disc
drives, DVDs, and JPEGs all involve fast finite Fourier transforms. This chapter
discusses both the computation and the interpretation of FFTs.
The acronym FFT is ambiguous. The first F stands for both “fast” and
“finite.” A more accurate abbreviation would be FFFT, but nobody wants to use
that. In Matlab the expression fft(x) computes the finite Fourier transform of
any vector x. The computation is fast if the integer n = length(x) is the product
of powers of small primes. We discuss this algorithm in section 8.6.
8.1 Touch-Tone Dialing
Touch-tone telephone dialing is an example of everyday use of Fourier analysis. The
basis for touch-tone dialing is the Dual Tone Multi-Frequency (DTMF) system. The
program touchtone demonstrates how DTMF tones are generated and decoded.
The telephone dialing pad acts as a 4-by-3 matrix (Figure 8.1). Associated with
each row and column is a frequency. These basic frequencies are
fr = [697 770 852 941];
fc = [1209 1336 1477];
If sis a character that labels one of the buttons on the keypad, the corre-
sponding row index kand column index jcan be found with
switch s
case ’*’, k = 4; j = 1;
case ’0’, k = 4; j = 2;
case ’#’, k = 4; j = 3;
otherwise,
d = s-’0’; j = mod(d-1,3)+1; k = (d-j)/3+1;
end
December 26, 2005
1
docsity.com
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15

Partial preview of the text

Download Fourier Analysis-Signal Processing And Analysis-Handout and more Exercises Signal Processing and Analysis in PDF only on Docsity!

Chapter 8

Fourier Analysis

We all use Fourier analysis every day without even knowing it. Cell phones, disc drives, DVDs, and JPEGs all involve fast finite Fourier transforms. This chapter discusses both the computation and the interpretation of FFTs. The acronym FFT is ambiguous. The first F stands for both “fast” and “finite.” A more accurate abbreviation would be FFFT, but nobody wants to use that. In Matlab the expression fft(x) computes the finite Fourier transform of any vector x. The computation is fast if the integer n = length(x) is the product of powers of small primes. We discuss this algorithm in section 8.6.

8.1 Touch-Tone Dialing

Touch-tone telephone dialing is an example of everyday use of Fourier analysis. The basis for touch-tone dialing is the Dual Tone Multi-Frequency (DTMF) system. The program touchtone demonstrates how DTMF tones are generated and decoded. The telephone dialing pad acts as a 4-by-3 matrix (Figure 8.1). Associated with each row and column is a frequency. These basic frequencies are

fr = [697 770 852 941]; fc = [1209 1336 1477]; If s is a character that labels one of the buttons on the keypad, the corre- sponding row index k and column index j can be found with

switch s case ’*’, k = 4; j = 1; case ’0’, k = 4; j = 2; case ’#’, k = 4; j = 3; otherwise, d = s-’0’; j = mod(d-1,3)+1; k = (d-j)/3+1; end

December 26, 2005

2 Chapter 8. Fourier Analysis

1209 1336 1477

697

770

852

941

Figure 8.1. Telephone keypad.

A key parameter in digital sound is the sampling rate.

Fs = 32768

A vector of points in the time interval 0 ≤ t ≤ 0 .25 at this sampling rate is

t = 0:1/Fs:0.

The tone generated by the button in position (k,j) is obtained by superimposing the two fundamental tones with frequencies fr(k) and fc(j).

y1 = sin(2pifr(k)t); y2 = sin(2pifc(j)t); y = (y1 + y2)/2;

If your computer is equipped with a sound card, the Matlab statement

sound(y,Fs)

plays the tone. Figure 8.2 is the display produced by touchtone for the ’1’ button. The top subplot depicts the two underlying frequencies and the bottom subplot shows a portion of the signal obtained by averaging the sine waves with those frequencies. The data file touchtone.mat contains a recording of a telephone being dialed. Is it possible to determine the phone number by listening to the signal generated? The statement

load touchtone

loads both a signal y and a sample rate Fs in the workspace. In order to reduce file size, the vector y has been saved with 8-bit integer components in the range − 127 ≤ yk ≤ 127. The statement

4 Chapter 8. Fourier Analysis

600 800 1000 1200 1400 1600 0

200

400

600

Figure 8.4. FFT of the recorded signal.

Figure 8.4 shows the magnitude of the FFT of the signal, which is the key to determining the individual digits. The plot was produced with

p = abs(fft(y)); f = (0:n-1)*(Fs/n); plot(f,p); axis([500 1700 0 600])

The x-axis corresponds to frequency. The axis settings limit the display to the range of the DTMF frequencies. There are seven peaks, corresponding to the seven basic frequencies. This overall FFT shows that all seven frequencies are present someplace in the signal, but it does not help determine the individual digits. The touchtone program also lets you break the signal into 11 equal segments and analyze each segment separately. Figure 8.5 is the display from the first seg- ment. For this segment, there are only two peaks, indicating that only two of the basic frequencies are present in this portion of the signal. These two frequencies come from the ’1’ button. You can also see that the waveform of a short portion of the first segment is similar to the waveform that our synthesizer produces for the ’1’ button. So we can conclude that the number being dialed in touchtones starts with a 1. Exercise 8.1 asks you to continue the analysis and identify the complete phone number.

8.2 Finite Fourier Transform

The finite, or discrete, Fourier transform of a complex vector y with n elements is another complex vector Y with n elements

Yk =

n∑− 1

j=

ωjkyj ,

where ω is a complex nth root of unity:

ω = e−^2 πi/n.

8.2. Finite Fourier Transform 5

−1 1 2 3 4 5 6 7 8 9

−0.

0

1

(^0600 800 1000 1200 1400 )

100

200

300

−1 0.38 0.385 0.39 0.395 0.4 0.405 0.41 0.415 0.

−0.

0

1

Figure 8.5. The first segment and its FFT.

In this chapter, the mathematical notation follows conventions common in signal processing literature where i =

−1 is the complex unit and j and k are indices that run from 0 to n − 1. The Fourier transform can be expressed with matrix-vector notation:

Y = F y,

where the Fourier matrix F has elements

fk,j = ωjk.

It turns out that F is nearly its own inverse. More precisely, F H^ , the complex conjugate transpose of F , satisfies

F H^ F = nI,

so

F −^1 =

n

F H^.

This allows us to invert the Fourier transform:

y =

n

F H^ Y.

Hence

yj =

n

n∑− 1

k=

Yk ω¯jk,

8.3. fftgui 7

real(y) imag(y)

real(fft(y)) imag(fft(y))

Figure 8.6. FFT of the first unit vector is constant.

real(y) imag(y)

real(fft(y)) imag(fft(y))

Figure 8.7. FFT of the second unit vector is a pure sinusoid.

if y 0 = 1 and y 1 = · · · = yn− 1 = 0. The result is

Yk = 1 · e^0 + 0 + · · · + 0 = 1 for all k.

Click y 0 again, hold the mouse down, and move the mouse vertically. The amplitude of the constant result varies accordingly. Next try the second unit vector. Use the mouse to set y 0 = 0 and y 1 = 1. This should produce Figure 8.7. You are seeing the graph of

Yk = 0 + 1 · e−^2 ikπ/n^ + 0 + · · · + 0.

8 Chapter 8. Fourier Analysis

The nth root of unity can also be written

ω = cos δ − i sin δ, where δ = 2π/n.

Consequently, for k = 0,... , n − 1,

real(Yk) = cos kδ, imag(Yk) = − sin kδ.

We have sampled two trig functions at n equally spaced points in the interval 0 ≤ x < 2 π. The first sample point is x = 0 and the last sample point is x = 2π − δ.

real(y) imag(y)

real(fft(y)) imag(fft(y))

Figure 8.8. FFT is the sum of two sinusoids.

Now set y 2 = 1 and vary y 4 with the mouse. One snapshot is Figure 8.8. We have graphs of cos 2kδ + η cos 4kδ and − sin 2kδ − η sin 4kδ

for various values of η = y 4. The point just to the right of the midpoint of the x-axis is particularly impor- tant. It is known as the Nyquist point. With the points numbered from 0 to n − 1 for even n, it’s the point with index n 2. If n = 32, it’s point number 16. Figure 8. shows that the fft of a unit vector at the Nyquist point is a sequence of alternating +1’s and −1’s. Now let’s look at some symmetries in the FFT. Make several random clicks on the real(y) plot. Leave the imag(y) plot flat zero. Figure 8.10 shows an example. Look carefully at the two fft plots. Ignoring the first point in each plot, the real part is symmetric about the Nyquist point and the imaginary part is antisymmetric about the Nyquist point. More precisely, if y is any real vector of length n and Y = fft(y), then

real(Y 0 ) =

yj , imag(Y 0 ) = 0, real(Yj ) = real(Yn−j ), imag(Yj ) = −imag(Yn−j ), j = 1,... , n/ 2.

10 Chapter 8. Fourier Analysis

Royal Observatory of Belgium [4]. The text file sunspot.dat in the Matlab demos directory has two columns of numbers. The first column is the years from 1700 to 1987 and the second column is the average Wolfer sunspot number for each year.

load sunspot.dat t = sunspot(:,1)’; wolfer = sunspot(:,2)’; n = length(wolfer); There is a slight upward trend to the data. A least squares fit gives the trend line.

c = polyfit(t,wolfer,1); trend = polyval(c,t); plot(t,[wolfer; trend],’-’,t,wolfer,’k.’) xlabel(’year’) ylabel(’Wolfer index’) title(’Sunspot index with linear trend’)

17000 1750 1800 1850 1900 1950

20

40

60

80

100

120

140

160

180

200

year

Wolfer index

Sunspot index with linear trend

Figure 8.11. Sunspot index.

You can definitely see the cyclic nature of the phenomenon (Figure 8.11). The peaks and valleys are a little more than 10 years apart. Now subtract off the linear trend and take the FFT. y = wolfer - trend; Y = fft(y);

The vector |Y |^2 is the power in the signal. A plot of power versus frequency is a periodogram (Figure 8.12). We prefer to plot |Y |, rather than |Y |^2 , because the

8.4. Sunspots 11

scaling is not so exaggerated. The sample rate for these data is one observation per year, so the frequency f has units of cycles per year.

Fs = 1; % Sample rate f = (0:n/2)Fs/n; pow = abs(Y(1:n/2+1)); pmax = 5000; plot([f; f],[0pow; pow],’c-’, f,pow,’b.’, ... ’linewidth’,2,’markersize’,16) axis([0 .5 0 pmax]) xlabel(’cycles/year’) ylabel(’power’) title(’Periodogram’)

(^00) 0.05 0.1 0.15 0.2 0.25 0.3 0.35 0.4 0.45 0.

500

1000

1500

2000

2500

3000

3500

4000

4500

5000

cycles/year

power

Periodogram

Figure 8.12. Periodogram of the sunspot index.

The maximum power occurs near frequency = 0.09 cycles/year. We would like to know the corresponding period in years/cycle. Let’s zoom in on the plot and use the reciprocal of frequency to label the x-axis.

k = 0:44; f = k/n; pow = pow(k+1); plot([f; f],[0*pow; pow],’c-’,f,pow,’b.’, ... ’linewidth’,2,’markersize’,16) axis([0 max(f) 0 pmax]) k = 2:3:41; f = k/n; period = 1./f; periods = sprintf(’%5.1f|’,period);

8.6. Fast Finite Fourier Transform 13

y data Fs samples/unit-time n = length(y) number of samples t = (0:n-1)/Fs total time dt = 1/Fs time increment

Y = fft(y) finite Fourier transform abs(Y) amplitude of FFT abs(Y).^2 power f = (0:n-1)(Fs/n) frequency, cycles/unit-time (n/2)(Fs/n) = Fs/2 Nyquist frequency p = 1./f period, unit-time/cycle

The periodogram is a plot of the FFT amplitude abs(Y), or power abs(Y).^2, versus the frequency f. You only need to plot the first half because the second half is a reflection of the first half about the Nyquist frequency.

8.6 Fast Finite Fourier Transform

One-dimensional FFTs with a million points and two-dimensional 1000-by- transforms are common. The key to modern signal and image processing is the ability to do these computations rapidly. Direct application of the definition

Yk =

n∑− 1

j=

ωjkyj , k = 0,... , n − 1 ,

requires n multiplications and n additions for each of the n components of Y for a total of 2n^2 floating-point operations. This does not include the generation of the powers of ω. A computer capable of doing one multiplication and addition every microsecond would require a million seconds, or about 11.5 days, to do a million-point FFT. Several people discovered fast FFT algorithms independently and many people have since contributed to their development, but it was a 1965 paper by John Tukey of Princeton University and John Cooley of IBM Research that is generally credited as the starting point for the modern usage of the FFT. Modern fast FFT algorithms have computational complexity O(n log 2 n) in- stead of O(n^2 ). If n is a power of 2, a one-dimensional FFT of length n requires fewer than 3n log 2 n floating-point operations. For n = 2^20 , that’s a factor of almost 35,000 faster than 2n^2. Even if n = 1024 = 2^10 , the factor is about 70. With Matlab 6.5 and a 700 MHz Pentium laptop, the time required for fft(x) if length(x) is 2^20 = 1048576 is about 1 s. The built-in fft function is based on FFTW, “The Fastest Fourier Transform in the West,” developed at M.I.T. by Matteo Frigo and Steven G. Johnson [2]. The key to the fast FFT algorithms is the fact that the square of the 2nth

14 Chapter 8. Fourier Analysis

root of unity is the nth root of unity. Using complex notation,

ω = ωn = e−^2 πi/n,

we have ω^22 n = ωn. The derivation of the fast algorithm starts with the definition of the finite Fourier transform:

Yk =

n∑− 1

j=

ωjkyj , k = 0,... , n − 1.

Assume that n is even and that k ≤ n/ 2 − 1. Divide the sum into terms with even subscripts and terms with odd subscripts.

Yk =

even j

ωjkyj +

odd j

ωjkyj

n/ ∑ 2 − 1

j=

ω^2 jky 2 j + ωk

n/ ∑ 2 − 1

j=

ω^2 jky 2 j+1.

The two sums on the right are components of the FFTs of length n/2 of the portions of y with even and odd subscripts. In order to get the entire FFT of length n, we have to do two FFTs of length n/2, multiply one of these by powers of ω, and concatenate the results. The relationship between an FFT of length n and two FFTs of length n/2 can be expressed compactly in Matlab. If n = length(y) is even,

omega = exp(-2pii/n); k = (0:n/2-1)’; w = omega .^ k; u = fft(y(1:2:n-1)); v = w.*fft(y(2:2:n));

then

fft(y) = [u+v; u-v];

Now, if n is not only even but actually a power of 2, the process can be repeated. The FFT of length n is expressed in terms of two FFTs of length n/2, then four FFTs of length n/4, then eight FFTs of length n/8, and so on until we reach n FFTs of length one. An FFT of length one is just the number itself. If n = 2p, the number of steps in the recursion is p. There is O(n) work at each step, so the total amount of work is

O(np) = O(n log 2 n).

If n is not a power of two, it is still possible to express the FFT of length n in terms of several shorter FFTs. An FFT of length 100 is two FFTs of length 50,

16 Chapter 8. Fourier Analysis

8.8 fftmatrix

The n-by-n matrix F generated by the Matlab statement

F = fft(eye(n,n))

is a complex matrix whose elements are powers of the nth root of unity

ω = e−^2 πi/n

The statement

plot(fft(eye(n,n)))

connects the elements of each column of F and thereby generates a subgraph of the graph on n points. If n is prime, connecting the elements of all columns generates the complete graph on n points. If n is not prime, the sparsity of the graph of all columns is related to the speed of the FFT algorithm. The graphs for n = 8, 9, 10, and 11 are shown in Figure 8.14.

8 9

10 11

Figure 8.14. Graphs of FFT matrix.

Because n = 11 is prime, the corresponding graph shows all possible connections. But the other three values of n are not prime. Some of the links in their graphs are missing, indicating that the FFT of a vector with that many points can be computed more quickly. The program fftmatrix allows you to investigate these graphs.

fftmatrix(n)

plots all the columns of the Fourier matrix of order n.

8.9. Other Fourier Transforms and Series 17

fftmatrix(n,j)

plots only the j+1st column.

fftmatrix

defaults to fftmatrix(10,4). In all cases, push buttons allow n, j and the choice between one or all columns be changed.

8.9 Other Fourier Transforms and Series

We have been studying the finite Fourier transform, which converts one finite se- quence of coefficients into another sequence of the same length, n. The transform is

Yk =

n∑− 1

j=

yj e−^2 ijkπ/n, k = 0,... , n − 1.

The inverse transform is

yj =

n

n∑− 1

k=

Yke^2 ijkπ/n, j = 0,... , n − 1.

The Fourier integral transform converts one complex function into another. The transform is

F (μ) =

−∞

f (t)e−^2 πiμtdt.

The inverse transform is

f (t) =

−∞

F (μ)e^2 πiμtdμ.

The variables t and μ run over the entire real line. If t has units of seconds, then μ has units of radians per second. Both of the functions f (t) and F (μ) are complex valued, but in most applications the imaginary part of f (t) is zero. Alternative units use ν = 2πμ, which has units of cycles or revolutions per second. With this change of variable, there are no factors of 2π in the exponen- tials, but there are factors of 1/

2 π in front of the integrals, or a single factor of 1 /(2π) in the inverse transform. Maple and the Matlab Symbolic Toolbox use this alternative notation with the single factor in the inverse transform. A Fourier series converts a periodic function into an infinite sequence of Fourier coefficients. Let f (t) be the periodic function and let L be its period, so

f (t + L) = f (t) for all t.

The Fourier coefficients are given by integrals over the period

cj =

L

∫ L/ 2

−L/ 2

f (t)e−^2 πijtdt, j =... , − 1 , 0 , 1 ,....

Exercises 19

8.2. Modify touchtone.m so that it can dial a telephone number specified by an input argument, such as touchtone(’1-800-555-1212’). 8.3. Our version of touchtone.m breaks the recording into a fixed number of equally spaced segments, each corresponding to a single digit. Modify touchtone so that it automatically determines the number and the possibly disparate lengths of the segments. 8.4. Investigate the use of the Matlab functions audiorecorder andaudioplayer, or some other system for making digital recordings. Make a recording of a phone number and analyze it with your modified version of touchtone.m. 8.5. Recall that the Fourier matrix F is the n-by-n complex matrix with elements

fk,j = ωjk,

where ω = e−^2 πi/n. Show that √^1 n F is unitary. In other words, show that F H^ , the complex conjugate transpose of F , satisfies

F H^ F = nI.

The notation here is a little unusual for matrices because the subscripts j and k run from 0 to n − 1, instead of from 1 to n. 8.6. What relationship between n and j causes fftmatrix(n,j) to produce a five-point star? What relationship produces a regular pentagon? 8.7. El Ni˜no. The climatological phenomenon el Ni˜no results from changes in atmospheric pressure in the southern Pacific ocean. The ‘Southern Oscillation Index’ is the difference in atmospheric pressure between Easter Island and Darwin, Australia, measured at sea level at the same moment. The text file elnino.dat contains values of this index measured on a monthly basis over the 14-year period 1962 through 1975. Your assignment is to carry out an analysis similar to the sunspot example on the el Ni˜no data. The unit of time is one month instead of one year. You should find there is a prominent cycle with a period of 12 months and a second, less prominent, cycle with a longer period. This second cycle shows up in about three of the Fourier coefficients, so it is hard to measure its length, but see if you can make an estimate. 8.8. Train whistle. The Matlab demos directory contains several sound samples. One of them is a train whistle. The statement

load train

gives you a long vector y and a scalar Fs whose value is the number of samples per second. The time increment is 1/Fs seconds. If your computer has sound capabilities, the statement

sound(y,Fs)

20 Chapter 8. Fourier Analysis

plays the signal, but you don’t need that for this problem. The data do not have a significant linear trend. There are two pulses of the whistle, but the harmonic content of both pulses is the same. (a) Plot the data with time in seconds as the independent variable. (b) Produce a periodogram with frequency in cycles/second as the indepen- dent variable. (c) Identify the frequencies of the six peaks in the periodogram. You should find that ratios between these six frequencies are close to ratios between small integers. For example, one of the frequencies is 5/3 times another. The frequencies that are integer multiples of other frequencies are overtones. How many of the peaks are fundamental frequencies and how many are overtones? 8.9. Bird chirps. Analyze the chirp sound sample from the Matlab demos di- rectory. By ignoring a short portion at the end, it is possible to segment the signal into eight pieces of equal length, each containing one chirp. Plot the magnitude of the FFT of each segment. Use subplot(4,2,k) for k = 1: and the same axis scaling for all subplots. Frequencies in the range from roughly 400 Hz to 800 Hz are appropriate. You should notice that one or two of the chirps have distinctive plots. If you listen carefully, you should be able to hear the different sounds.