help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Any FFT expert around?


From: Brian Kaczynski
Subject: Re: Any FFT expert around?
Date: Wed, 12 Feb 2014 14:29:25 +0100

Hi Oxy,

The frequency vector for FFT should go from DC as bin 1 to slightly less than Fs in the last bin (Fs - Fs/N where N is the number of FFT points).

If you want to plot this as a range from -Fs/2 to +Fs/2 (minus the same fraction) you can do this, but in this case you should use the fftshift function as follows:

freqsig = fftshift(fft(tdsig));

Also, make sure you are intending to plot the REAL part of the FFT only (I believe that is the default behavior for how you are executing the plot).

-Brian


2014-02-12 14:22 GMT+01:00 oxy <address@hidden>:
hey guys,

the (simple) code bellow is how i ve learned to do FFT according to
several docs online. However i observe a dependency of the signal
frequency in the spectrum on the constant FsFactor. In other words,
the signal frequency depends on the sampling rate. I should'nt be,
right? So what is wrong here?

  #---------- start code ------------
  clear all
  nu=10;                    % signal frequency
  at=5;                       % acquisition time
  T1=2                       % signal decay constant in time domain
  FsFactor=8;             % the ratio (sampling rate)/(signal
frequency), or Fs/nu

  clf
  Fs = FsFactor*nu;                             % Sampling rate
  t = ((0:(at*Fs-1))/Fs)';                         % Time vector
  freq=linspace(-1,1,Fs*at)' * Fs/2;         % frequency vector
  tdsig=exp(-i*2*pi*nu*t).*exp(-t./(T1));    % time domain signal
  freqsig=fft(tdsig);                                % freq. domain signal
  subplot(1,2,1)
  plot(t,tdsig)
  axis([ 0 0.4])       % zooming time domain to see that period=1/nu
  subplot(1,2,2)
  plot(freq, freqsig)
  #---------- end code ------------

Do it yourself. Just rerun the code trying different values of
FsFactor (eg: 2, 4, 8).
Thx a lot for any hint!!!

oxy

ps: cross post http://www.mathworks.com/matlabcentral/answers/115700-fft-why-signal-frequency-depends-on-sampling-rate
_______________________________________________
Help-octave mailing list
address@hidden
https://mailman.cae.wisc.edu/listinfo/help-octave


reply via email to

[Prev in Thread] Current Thread [Next in Thread]