Calculates an N point FFT by zero padding or time aliasing.
NFFT(series, N, wintype, ampflag)
series |
- |
An input series |
||||||||||||||||||||
N |
- |
Optional. An integer, the FFT length. Defaults to the length of the input series. |
||||||||||||||||||||
wintype |
- |
Optional. An integer, the windowing function.
|
||||||||||||||||||||
ampflag |
- |
Optional. An integer. Windowing amplitude correction method.
|
A complex series or array, the N point FFT of the input.
W1: 1..12
W2: nfft(w1, 20)
W3: nfft(w1, 4)
W4: decimate(fft(w1), 3)
W2 contains 20 samples of the FFT of W1 with 8 zeros appended for an input length of 20. W3 contains 4 samples of the FFT of W1. This is numerically equivalent to decimating the full FFT by 3 as shown in W4, but because a 4 point FFT is calculated, the computation is performed more quickly.
W1: 1..12
W2: nfft(w1, 20, 3)
W3: nfft(w1, 4, 3)
W4: decimate(fft(kaiser(w1)), 3)
Same as the first example except a Kaiser window is employed.
NFFT computes N equally spaced samples of the FFT by zero padding if N is greater than the series length or by time aliasing the input series if N is less than the series length.
For N < length(s), the result is numerically equivalent to decimating the full FFT (where the number of samples is equal to length(s)), however, the computation is generally faster since a shorter FFT is computed.
If a windowing function is specified, the window is applied to the entire input series.
If ampflag == 1, the correction factor is the mean of the spectral window. This assures that the spectrum of a sinusoid of amplitude A has a peak of A.
If ampflag == 2, the correction is applied as follows:
w = winfun(s) * rms(s) / rms(winfun(s))
where winfun is Blackman, Blackmanharris, Flattop, Hamming, Hanning or Kaiser. This assures that:
sqrt(area(psd(w))) == rms(s) approximately
If ampflag == 3, the correction is applied as follows:
w = winfun(s) / sqrt(mean(win * win)
where win is the windowing function.
See DADiSP/FFTXL to optimize the underlying FFT computation.