FFT: why signal frequency depends on sampling rate?

6 views (last 30 days)
hey guys,
the 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. I should'nt be, right? So what is wrong here?
clear all
nu=10;
at=5;
T1=2
FsFactor=8;
clf
Fs = FsFactor*nu; % Sampling freq.
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])
subplot(1,2,2)
plot(freq, freqsig)
Do it yourself. Just rerun the code trying different values of FsFactor (eg: 2, 4, 8). Thx for any tip!!!
  1 Comment
Suneesh
Suneesh on 11 Feb 2014
I changed the code to:
clear all
nu=10;
at=5;
T1=2;
FsFactor=4;
Fs = FsFactor*nu; % Sampling freq.
t = ((0:(at*Fs-1))/Fs)'; % Time vector
freq=linspace(-1,1,Fs*at)' * Fs/2; % frequency vector
tdsig=exp(-1i*2*pi*nu*t).*exp(-t./(T1)); % time domain signal
freqsig=fft(tdsig); % freq. domain signal
figure;
subplot(1,2,1)
plot(t,tdsig)
subplot(1,2,2);
plot(freq, abs(freqsig))

Sign in to comment.

Answers (4)

Suneesh
Suneesh on 11 Feb 2014
I guess your question is about the X axis of the frequency plot varying with different values of FsFactor. This is because you are looking at the X axis values literally whereas you should be actually looking at normalized frequencies. If your sample rate is 1000Hz then Nyquist Sampling Theorem tells us that such a sampled signal can accurately (perfect reconstruction) depict a signal containing up to only 1000/2Hz = 500Hz. So in this case the normalized X axis corresponds as follows: [0:1] is representative of 0Hz to 500Hz. Most introductory DSP books cover this in the first few sections.

oxy opes
oxy opes on 11 Feb 2014
Hi suneesh,
if i look at the code, the frequency vector is exactly according to niquyst:
freq=linspace(-1,1,Fs*at)' * Fs/2;
will create a vector between -Fs/2 and Fs/2, Fs being the sampling rate. Thus where is the problem?

Youssef  Khmou
Youssef Khmou on 11 Feb 2014
FFT is correct as long as the Sampling rate is twice bigger than the maximum frequency of the signal, in the other hand resolution of the frequency increases if you compute the spectrum with high number of points,

oxy opes
oxy opes on 11 Feb 2014
hi youssef, i agree. If you look at the frequency vector, it increases size toguether with the acquisition time (at):
freq=linspace(-1,1,Fs*at)' * Fs/2;
Thus everything seems to be right. But the signal frequency still depends on the variable FsFactor. I even plotted the time domain signal and confirmed that the period of the oscillation is conformant to the frequency nu.
So I just cannot find the problem here!?
Thx anyway...

Community Treasure Hunt

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

Start Hunting!