12.07.2015 Views

Basics of MATLAB and Beyond

Basics of MATLAB and Beyond

Basics of MATLAB and Beyond

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

The top trace in the top plot is the noisy data, <strong>and</strong> the bottom trace isthe original pure sinusoid. The lower plot clearly shows the frequency at100 Hz.Two GUI-based FFT demos can be accessed by typing demo at theprompt. Select the “Signal Processing” option, then choose the “DiscreteFourier Transform” or the “Continuous Fourier Transform”.Exercise 5 Extend the ideas in the previous example to twodimensions, as would be the case, for example, if you made measurementsin space <strong>and</strong> time, rather than time alone. Generatea two-dimensional sinusoid <strong>and</strong> explore its FFT. (Answer onpage 185.)18 Power SpectrumThe power spectrum (or power spectral density, or PSD) is a measure<strong>of</strong> the power contained within frequency intervals. The problem is thatwe only have a finite set <strong>of</strong> samples <strong>of</strong> the true signal so we can neverhave perfect knowledge about its power spectrum. A common way toestimate a PSD is to use the square <strong>of</strong> the FFT <strong>of</strong> the samples. Thesquare <strong>of</strong> the FFT is called the periodogram. The workhorse <strong>of</strong> matlab’speriodogram-based spectral estimation is the spectrum function(in the Signal Processing Toolbox). We illustrate using data similar tothe previous example <strong>of</strong> a noisy sinusoid, but we take more samples. APSD estimate can be found by typing:dt = 1/1000;t = dt:dt:8192*dt;sine = sin(2*pi*100*t);y = sine + r<strong>and</strong>n(size(t));clfspectrum(y)The frequency scale is normalised to the Nyquist frequency. The middleline is the PSD estimate <strong>and</strong> the two dashed lines are the 95% confidenceintervals. Typing help spectrum reveals that there are manyparameters that you can adjust when calculating the power spectrum.matlab’s spectrum function uses the Welch method <strong>of</strong> PSD estimation, 6which divides a long signal into a number <strong>of</strong> smaller blocks, calculates6 See Alan V. Oppenheim <strong>and</strong> Ronald W. Schafer, Digital Signal Processing,Prentice-Hall, 1975, p. 553. An excellent general treatment <strong>of</strong> PSD estimation isalso given in William Press, Brian Flannery, Saul Teukolsky <strong>and</strong> William Vetterling,Numerical Recipes, Cambridge University Press, 1989.c○ 2000 by CRC Press LLC

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!