Frequency vector and fft I have got a question concerning the definition of the frequency vector for an fft operation.

Generally, I work with a frequency vector, f, with power of 2 elements (2048, 4096, 8192, ...).

Given a certain simulation analysis time, time (e.g. 600s), I should define f as follows:

% Frequency defition
t = 0:dt:(time-dt);
df = 1/(time);
fn = Nfft/time;


$$ f = -f_{n}/2:df:f_{n}/2-1; $$

where $ f_{n} $ represent the Nyquist cut-off frequency.

Actually, for:


computational reasons
symmetry of the power spectra along f axis
not throwing away real or imag part of the fft


I aim to define only half of the frequency range, as for example

$$ f = 0:df:f_{n}/2-1; $$

After calling the fft of my input signal, I would get the desired time series as

ouput = [real(fft) imag(fft)];


But, this way, I count the 0 frequency term twice and the -fn/2 is completely discarded.

How would it be possible to emcompasses the whole standard frequency range starting from only half of it?
The proper way to define your frequency vector after a DFT is as follows. Let $N$ be your DFT length, and $f_s$ be your sampling rate in Hz. Furthermore, define an $N$-length frequency vector $\bf{f}$, where each element $f_i = i$, for $i = 0, 1, 2, ... N-1$.

Now your frequency vector in hertz is simply going to be $\bf{f}$$\frac{f_s}{N}$

Now, assuming you are DFT'ing a real sequence, simply pick all elements with frequency values less than $\frac{f_s}{2}$, and you are in business!

You can also see my answer here for actual code.