|
From: | Brian Kaczynski |
Subject: | Re: Any FFT expert around? |
Date: | Wed, 12 Feb 2014 17:24:00 +0100 |
Hi Brian,
> 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 i understand u correctly, the frequency vector (freq) must be written
as in this modified version of code below. However, according to Nyquist we
cannot measure a frequency higher than Fs/2. Thus i do not see
the meaning of plotting up to ~Fs.
Also, if I rerun the code below changing FsFactor, I again see this
dependency of the signal frequency on FsFactor.
I cannot understand it. Looks like basics, yet not that obvious.
#---------- start code ------------
clear all
nu=10; % signal frequency
at=5; % acquisition time
T1=2 % signal decay constant in time domain
FsFactor=16; % 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, first version
freq=linspace(0,1,Fs*at)' * Fs- Fs/(Fs*at); % frequency vector
suggested by Brian
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 ------------
thx guys ...
> 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
>>
>
_______________________________________________
Help-octave mailing list
address@hidden
https://mailman.cae.wisc.edu/listinfo/help-octave
[Prev in Thread] | Current Thread | [Next in Thread] |