1
$\begingroup$

I have a doubt related to calculating the Discrete Time Fourier Transform (DTFT) by hand. Specifically in how calculate the frequency axis of the spectrum. My signal has N values and was sampled at FS Hz, the spectrum would have N entries too (where N/2 values are a mirror of the other half). The maximum representable frequency is FS/2 (by the Nyquist theorem), that means that I have to multiply each entry by FS/N, so for the last entry (N/2) I have this:

(FS/N) * (N/2) = FS/2

But when I sample at a higher FS Hz the spectrum is shifted. Think for instance in this function:

x = cos(2*pi*f0*t)

Where "f0 = 1/T", T is the period of the cosine and "t" means each entry of the time axis. Then the spectrum is two pulses in "-f0" and "f0". But doing this in python:

f = range(-N/2,N/2)
f = [float(FS)/(float(N)) * i for i in f]

And sampling at a higher FS, then the pulses are shifted. But the correct behavior is that the pulses remain in the same location ("-f0" and "f0"), because the cosine function period didn't change. Am I doing something wrong?

Thanks in advance ;)

PD: I know that increasing the sampling rate would increase the density of the spectrum and the time signal too, so N is going bigger automatically, because I would have more samples per second.

$\endgroup$
  • $\begingroup$ what is fm in your code? $\endgroup$ – geometrikal Jan 21 '14 at 1:46
  • $\begingroup$ Sorry, it was a typo. It is FS (frequency rate or sampling frequency). That code line is simply multiplying each array entry by an scalar. $\endgroup$ – JFonseca Jan 21 '14 at 13:57
  • $\begingroup$ Adding two more links: link1, link2 $\endgroup$ – JFonseca Jan 24 '14 at 19:24
0
$\begingroup$

Generally I like to compose my sinusoids using this format:

x = cos(2*pi*f/fs*(0:num_samps-1))

Depending on the FFT routine you will use it will provide either the onesided or twosided result. Calculating the domain of the frequency axis is as follows. It should be noted that num_samps and NFFT may not be the same.

% Nfft - FFT size
% Fs - Sampling frequency in Hz
% oneside - flag indicating FFT results will be onesided or two sided

% Compute the frequency vector
if oneside == true
  f = fs * (0:Nfft/2).'./Nfft;
else
  f = fs * (-Nfft/2:Nfft/2-1).'./Nfft;
end

Have a look at this paper for a nice explanation on spectrum estimation.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.