Generate frequency-domain abscissa for FFT data.
xf = fdaxis(dT,N) xf = fdaxis(xt)
This function returns a vector xf
of the frequencies of the FFT
of a N
-point time-domain signal with time step dT
.
dT
can have any unit, the unit of xf
is simply its inverse. So for
dT
in μs, xf
is in plain MHz (or Mc in old
notation), not in angular frequency units.
In its second call form, the function takes the full time-domain
abscissa as input parameter. E.g., xt = (0:10)*0.1
corresponds to
dT = 0.1
and N = 11
.
The DC component of the FFT abscissa xf
is always in the centre.
The output of MATLAB's fft
returns the DC component as the first
element. So be sure that you either apply fftshift
to your data
after fft
or to xf
in order to get correct results.
For a 512-point signal tdata
sampled with time increments
of 8 ns, the frequency domain abscissa in MHz is
N = 512; dT = 0.008; % dT is in microseconds xf = fdaxis(dT,N); % xf is in MHz
The correct plot of the magnitude FFT of tdata
is
tdata = rand(1,N); % a signal with very low SNR ... fdata = abs(fft(tdata)); plot(xf,fftshift(fdata)); % use of fftshift xlabel('frequency [MHz]');
The discrete frequencies in the frequency-domain abscissa are apart. The vector always contains the frequency zero, but the start and end frequencies depend on whether N is odd or even.
If N is odd, there is the same number of negative and positive discrete frequencies, and the Nyquist frequency itself is not contained. If N is even, the negative Nyquist frequency is the first element of the vector, and it contains one more negative frequency than positive ones (always excluding zero).