What determines the maximum frequency when taking the FFT?

37 views (last 30 days)
L'O.G. on 2 May 2022
Commented: Star Strider on 2 May 2022
This is part conceptual, part MATLAB, but how do you set the maximum frequency when taking the FFT of a signal? According to the Nyquist, the frequency is set by something like
Freq = (df/2)*linspace(0,1,nfft/2+1);
where df is the spacing and nfft determines the length, but how do you determine the maximum?

Answers (2)

Star Strider
Star Strider on 2 May 2022
The maximum is the Nyquist frequency, since that is the highest frequency that is uniquely resolvable in a sampled signal.
I am not certain what ‘df’ is, however if it is the sampling frequency of the original signal, then that is correct. This suggests that ‘nfft’ is something different from the length of the original signal vector, so the frequency resolution will be different as ‘nfft’ changes. The fundamental characteristic of the fft however, including the Nyquist frequency, does not change with changing values for ‘nfft’.
Star Strider
Star Strider on 2 May 2022
Thank you!
The Nyquist frequency is one-half the sampling frequency.
This assumes that the sampling intervals are constant, such that the sampling frequency is the inverse of any single sampling interval. If they are not constant, they need to be interpolated to constant intervals with the resample function. This is necessary for essentially all signal processing on the signal, since all filtering and other operations assume constant sampling intervals. (The nufft function for non-uniformly sampled signals was introduced in R2020a, however it produces regularly-spaced frequencies. Its inverse would produce regularly-spaced time samples.)
The frequency vector calculation in your original post was introduced in the R2015a fft documentation, and remains valid.

Sign in to comment.

Paul on 2 May 2022
Hi L'O.G.
If X is the output of Matlab's fft() function, then the corresponding frequency vector is:
N = numel(X);
wn = (0:(N-1))/N*2*pi, where wn has units of rad/sample (or just rad if you like), Nyquist frequency is wn = pi
wn can then be scaled to convert to other representations:
fn = wn/2/pi (cycles/sample), Nyquist frequency is fn = 1/2
wc = wn/Ts (rad/sec) where Ts is the sampling period (sec) applied to the underlying continuous-time signal used to form the input sequence to fft(), Nyquist frequency is pi/Ts
fc = wn/2/pi/Ts (cycles/sec, or Hz), Nyquist frequency is 1/Ts/2 or fs/2 where fs = 1/Ts





Community Treasure Hunt

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

Start Hunting!