next Zero-padding
up Music 270a: Matlab Tutorial 3
previous FFT of a simple sinusoid


FFT of a slightly less simple sinusoid

The above example was somewhat contrived. It is more likely that the signals you analyse will have inusoidal components that don't complete a full cycle or, said differently, have frequency components that lie between fft bins. Let's see what happens in such a case.

First, increase the frequency in the above example by one-half of a bin:

% Example 2 = Example 1 with frequency between bins

f = 0.25 + 0.5/N;   % Move frequency up 1/2 bin

x = cos(2*pi*f*nT); % Signal to analyze
X = fft(x);         % Spectrum

Plot the resulting magnitude spectrum as you did above. Notice that at this frequency, we get extensive ``spectral leakage'' into all the side bins. To get an idea of where this is coming from, let's look at the periodic extension of the time waveform:

% Plot the periodic extension of the time-domain signal
plot([x x],'k');
title('Time Waveform Repeated Once');
xlabel('Time (samples)'); ylabel('Amplitude');

Notice the ``glitch'' in the middle where the signal begins its forced repetition. This results in ``undesirable'' frequency components in our spectrum.


next Zero-padding
up Music 270a: Matlab Tutorial 3
previous FFT of a simple sinusoid

``CMPT 318: Fundamentals of Computerized Sound'' by Tamara Smyth, Computing Science, Simon Fraser University.
Download PDF version (matlabtut3.pdf)
Download compressed PostScript version (matlabtut3.ps.gz)

Copyright © 2013-01-28 by Tamara Smyth.
Please email errata, comments, and suggestions to Tamara Smyth<trsmyth@ucsd.edu>