File Exchange

image thumbnail

autofft - FFT analyzer

version 1.2.5 (5.94 KB) by Lubos Smolik
Frequency analyser useful for interpretation of experimental data or a comparison of theoretical results with measurements.


Updated 10 Jun 2020

View Version History

View License

Signal Processing Toolbox™ provides several functions to power spectrum estimation, including pspectrum and stft. Although these functions are excellent and well-documented, they might be cumbersome in some engineering applications. These applications include estimating magnitudes of vibration, noise and other discrete-time signals in engineering units or a comparison of theoretical results with measurements.

In such applications, you can use autofft, a Matlab function for estimation of the discrete Fourier transform (DFT) which mimics options of the Brüel & Kjaer FFT analysers. Based on your input, autoFFT segments signal, applies window functions and spectral averaging. The resulting DFT can be returned in various engineering spectral units including magnitude, RMS, peak-to-peak and power spectral density (PSD). autofft can also estimate spectral derivation or spectral integral of DFT and even perform the short-time Fourier transform (STFT).

Note that autoFFT requires the Signal Processing Toolbox in order to generate window functions and estimate PSD accurately.

If you have any suggestions and comments or if you want to report a bug, feel free to contact me via e-mail carlist(at)

Cite As

Lubos Smolik (2020). autofft - FFT analyzer (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (6)


Is it possible to use this function to evaluate a stft? Given a displacement vector x and a time vector t, evaluate the frequency components of x for different values of times (and plot it in a waterfall plot)?


Lubos Smolik

@Attskij Sotona

fftset = struct('nwin', nfft, ... % Specifies the number of DFT points
'unit', 'psd'); % Specifies the spectral unit
[s, freq] = autfft(x, fs, fftset);

Note that if If nfft is less than the signal length, autofft behaves differently than periodogram because autofft averages result in the frequency domain rather than time domain.

For example, the input signal [1 2 3 4 5 6 7 8] with nfft equal to 4 results in the periodogram of sum([1 5; 2 6; 3 7; 4 8],2). However, it results in the averaged power spectral density from segments [1 2 3 4], [3 4 5 6], [5 6 7 8] in the case of autofft. The overlapping percentage of individual segments can be controlled with 'overlap' parameter.

Attskij Sotona

Thanks for sharing, looks great!
One question please. What's params for this function to get an equivalent of "periodogram(x, [], nfft, fs, 'psd', 'onesided');" ?

Attskij Sotona

jinpeng xing

MATLAB Release Compatibility
Created with R2020a
Compatible with R2013a to R2020a
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!