next Using a window
up Music 270a: Matlab Tutorial 3
previous FFT of a slightly less simple sinusoid


Zero-padding

To get finer resolution in the frequency domain, we can zero-pad the signal, that is, append zeroes to the end of the time-domain signal.

zpf = 8;            % zero-padding factor
x = [cos(2*pi*f*nT),zeros(1,(zpf-1)*N)]; % zero-padded 
X = fft(x);         % interpolated spectrum
magX = abs(X);      % magnitude spectrum
...                 % waveform plot as before
nfft = zpf*N;       % FFT size = new frequency grid size
fni = [0:1.0/nfft:1-1.0/nfft]; % normalized freq axis
subplot(3,1,2);
% with interpolation, we can use solid lines '-':
plot(fni,magX,'-k'); grid on; 
...
spec = 20*log10(magX); % spectral magnitude in dB
% clip below at -40 dB:
spec = max(spec,-40*ones(1,length(spec))); 
...                 % plot as before


next Using a window
up Music 270a: Matlab Tutorial 3
previous FFT of a slightly less 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>