MATLAB Answers

Correct choice of one sided frequency axis after fft

40 views (last 30 days)
FW on 7 Jul 2019
There are a lot of queries on fft frequency. I guess the following point not discussed anywhere explicitly (at least at one place). Hope someone can provide an insight here.
If we have and even number of data points, N=10, the fft output arranges the data as
fft = [c0, c1, c2, c3, c4, c-5, c-4, c-3, c-2, c-1], where the numbers are subscripts corresponding to positive and negative frequencies. I read somewhere that MATLAB calculates the negative coefficient first, hence we have c-5 but not c5. The author did not explain the reason.
Point no. 1, that the c values are not symmetric.
When we wish to make two-sided frequency spectrum, the frequency axis ranges from [-(N/2): (N/2)-1]*Fs/ N. Fs is the sampling rate, N is the number of even data points.
If we wish to make a one-sided positive frequency spectrum, should we choose
A) [0:(N/2)]*Fs/N and ignore the fact the we are using the values corresponding to the negative frequency axis, given that the data is a real number and it is just a mirror image.
B) [0: (N/2)-1]*Fs/N represents the true positive frequency axis?
If Fs= 250 Hz, the true positive frequency axis will end at 124.9980 Hz
If we happen to choose the negative frequency axis values and ignore the frequency sign, the frequency axis ends at 125 Hz exactly.
The same data when plotted in Origin ends the frequency axis at 125 Hz when plotted single sidedly.
Which approach is rigorously correct? Thanks.


dpb on 9 Jul 2019
Bruno, the n-1 is just the offset difference between 1- and 0-based arrays--a trivial difference but seems to throw many into complete tizzy.
Your latter illustration is also pertinent, I was just too lazy to write the extra code figuring simply showing OP the indexing is the root answer of how Matlab returns the order and one can build the quoted author's table from it by inspection.
Bruno Luong
Bruno Luong on 9 Jul 2019
"difference between 1- and 0-based arrays"
It escapes me about who was discussing of 1/0 base indexing in this thread.
As I understood the discussion is around the FFT output coefficients c_i and its subindex i which makes the correspondance to the frequency:
f(i) := Fs * i / n.
and whereas i should vary beween
[-floor((n-1)/2) : ceil((n-1)/2)] % OriginPro
[-ceil((n-1)/2) : floor((n-1)/2)] % MATLAB FFTSHIFT
(As we discuss, both are mathematically correct and it's a matter of interpretation or arbitrary choice)
Bjorn Gustavsson
Bjorn Gustavsson on 9 Jul 2019
@dpb (on 7 Jul 2019 at 14:50): One "common" use of "not choosing" base-band is that one has undersampled a high-frequency signal with signal at frequencies inside the N-th Nyqvist zone. The spectra of that signal can then be accurately determined with sampling-rates much lower than the centre-frequency of the band.

Sign in to comment.

Answers (0)

Community Treasure Hunt

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

Start Hunting!