index previous next

Harmonic analysis and the Fourier Transform

Some signals exhibit periodic components that repeat at fixed intervals throughout the signal, like a sine wave. It is often useful to describe the amplitude and frequency of such periodic components exactly. Actually, it is possible to analyze any arbitrary set of data into periodic components, whether or not the data appear periodic. Harmonic analysis is conventionally based on the Fourier transform, which is a way of expressing a signal as a sum of sine and cosine waves. It can be shown that any arbitrary discretely sampled signal can be described completely by the sum of a finite number of sine and cosine components whose frequencies are 0,1,2,3 ... n/2 times the fundamental frequency f=1/nx, where x is the interval between adjacent x-axis values and n is the total number of points. The Fourier transform is simply the coefficients of these sine and cosine components.

The concept of the Fourier transform is involved in two very important instrumental methods in chemistry. In Fourier transform infrared spectroscopy (FTIR), the Fourier transform of the spectrum is measured directly by the instrument, as the interferogram formed by plotting the detector signal vs mirror displacement in a scanning Michaelson interferometer. In Fourier Transform Nuclear Magnetic Resonance spectroscopy (FTNMR), excitation of the sample by an intense, short pulse of radio frequency energy produces a free induction decay signal that is the Fourier transform of the resonance spectrum. In both cases the spectrum is recovered by inverse Fourier transformation of the measured signal.

The power spectrum or frequency spectrum is a simple way of showing the total amplitude at each of these frequencies; it is calculated as the square root of the sum of the squares of the coefficients of the sine and cosine components.

Figure 10. The signal on the left (x = time; y = voltage), which was expected to contain a single peak, is clearly very noisy. The power spectrum of this signal (x-axis = frequency in Hz) shows a strong component at 60 Hz, suggesting that much of the noise is caused by stray pick-up from the 60 Hz power line. The smaller peak at 120 Hz (the second harmonic of 60 Hz) probably comes from the same source.

A signal with n points gives a power spectrum with only (n/2)+1 points. The x-axis is the harmonic number. The first point (x=0) is the zero-frequency (constant) component. The second point (x=1) corresponds to the fundamental frequency, the next point (x=2) to twice the fundamental frequency, the next point (x=3) to three times the fundamental frequency, etc. An example of a practical application of the use of the power spectrum as a diagnostic tool is shown in Figure 10.

The figures above show a classic example of harmonic analysis of the annual variation in the number of observed sunspots, which have been recorded since the year 1700! In this case the time axis is in years. A plot of the power spectrum (on the left) shows a strong peak at 0.09 cycles/year; if the data are replotted with time (the reciprocal of frequency) on the x-axis, the plot shows the well-known 11-year cycle.  (You can download these yearly sunspot data from NOAA at ftp://ftp.ngdc.noaa.gov/STP/SOLAR_DATA/SUNSPOT_NUMBERS/INTERNATIONAL/yearly/YEARLY.PLT).

In the examples shown above, the signal is a time-series signal with time as the independent variable. More generally, it is also possible to compute the Fourier transform and power spectrum of any signal, such as an optical spectrum, where the independent variable might be wavelength or wavenumber, or an electrochemical signal, where the independent variable might be volts, or a spacial signal, where the independent variable might be mm or cm. In such cases the units of the x-axis of the power spectrum are simply the reciprocal of the units of the x-axis of the original signal (e.g. nm-1 for a signal whose x-axis is in nm).

Software details

Microsoft Excel has a add-in function that make it possible to perform Fourier transforms relatively easily: (Click Tools > Add-Ins... > Analysis Toolpak > Fourier Analysis).  See http://www.brainmapping.org/NITP/PNA/tests/ProblemSet3_files/FourierExcel.htm.  See http://www.bowdoin.edu/~rdelevie/excellaneous/ for an extensive collection of add-in functions and macros for Excel, courtsey of Dr. Robert deLevie of Bowdoin College.
SPECTRUM, the freeware signal-processing application that accompanies this tutorial, includes a power spectrum function, as well as forward and reverse Fourier transformation.
Matlab has built-in functions for computing the Fourier transform (FFT and IFFT). The power spectrum of a signal vector "s" can be computed as real(sqrt(FFT(s) .* conj(FFT(s)))). For an example, see http://www.mathworks.com/products/matlab/demos.html?file=/products/demos/shipping/matlab/sunspots.html

iPower: Interactive Power Spectrum Demo for Matlab (version 2)

Click to view enlarged figure
Keyboard-operated version for Matlab 7.8

Click to view enlarged figure

Slider-operated version for Matlab 6.5

iPower: Keyboard-controlled interactive power spectrum demonstrator, useful for teaching and learning about the power spectra of different types of signals and the effect of signal duration and sampling rate. Single keystrokes allow you to select the type of signal (12 different signals included), the total duration of the signal, the sampling rate, and the global variables f1 and f2 which are used in different ways in the different signals. When the Enter key is pressed, the signal (y) is sent to the Windows WAVE audio device. Press K to see a list of all the keyboard commands. Tested in Matlab version 7.8 (R2009a).

Click here to view or download.  You can also download it from the Matlab File Exchange. T. C. O'Haver (toh@umd.edu), version 2, October 2011

KEYBOARD CONTROLS:
 Adjust signal duration 10% up/down.........A,Z
 Adjust sampling rate 10% up/down...........S,X
 Adjust first variable 10% up/down......... D,C
 Adjust second variable 10% up/down........ F,V
 Cycle through Linear/Log plot modes..........L
 Switch X-axis scale of power spectrum........H
 Print keyboard commands......................K
 Play signal as sound................Enter or P

                    
PRE-PROGRAMMED SIGNAL TYPES
*Sine wave, frequency f1 (Hz), phase f2
*Square wave, frequency f1 (Hz), phase f2
*Sawtooth wave, frequency Ff1(Hz)
*Triangle wave, frequency f1 (Hz), phase f2
*Sine wave burst of frequency f1 (Hz) and length f2 sec
*440 Hz carrier amplitude modulated by sine wave, frequency f1 (Hz) and amplitude f2
*440 Hz carrier frequency modulated by sine wave of frequency f1 (Hz) and amplitude f2
*Sine wave, frequency f1 (Hz), modulated with Gaussian of width f2 sec
*Sine wave, frequency f1 (Hz) with non-linear transfer function f2
*Sine wave sweep from 0 to f1 (Hz)
*Sine wave of frequency f1 (Hz) and amplitude f2 plus random white noise
*Pink (1/f) noise
*Sine wave, frequency f1 (Hz), amplitude f2 plus pink noise

There is also an older slider-operated version (see left) for Matlab version 6.5. Click here to view or download.

index previous next
Last updated November, 2011. This page is maintained by Prof. Tom O'Haver , Department of Chemistry and Biochemistry, The University of Maryland at College Park. Comments, suggestions and questions should be directed to Prof. O'Haver at toh@umd.edu.
Unique visits to this site since May 17, 2008: