Fourier Transforms for Continuous/Discrete Time/Frequency
Spectral Interpolation
Zero-Phase Zero Padding
Matlab/Octave fftshift utilitySearch Spectral Audio Signal Processing
Would you like to be notified by email when Julius Orion Smith III publishes a new entry into his blog?
Matlab and Octave have a simple utility called fftshift that performs this bin rotation. Consider the following example:
octave:4> fftshift([1 2 3 4]) ans = 3 4 1 2 octave:5>If the vector [1 2 3 4] is the output of a length 4 FFT, then the first element (1) is the dc term, and the third element (3) is the point at half the sampling rate (
Another reasonable result would be fftshift([1 2 3 4]) == [4 1
2 3], which defines half the sampling rate as a positive frequency.
However, giving
to the negative frequencies balances giving dc
to the positive frequencies, and the number of samples on both sides
is then the same. For an odd-length DFT, there is no point at
, so the result
octave:4> fftshift([1 2 3]) ans = 3 1 2 octave:5>is the only reasonable answer, corresponding to frequencies
Index Ranges for Zero-Phase Zero-Padding.
Having looked at zero-phase zero-padding ``pictorially'' in matlab
buffers, let's now specify the index-ranges mathematically. Denote
the window length by
(an odd integer) and the FFT length by
(a power of 2). Then the windowed data will occupy indices 0 to
(positive-time segment), and
to
(negative-time segment). Here we are assuming a 0-based indexing
scheme as used in C or C++. We add 1 to all indices for matlab
indexing to obtain 1:(M-1)/2+1 and N-(M-1)/2+1:N,
respectively. The zero-padding zeros go in between these ranges,
i.e., from
to
.
Summary.
To summarize, zero-padding is used for
Some examples of interpolated spectral display by means of zero-padding may be seen in §3.4.
