MATLAB: Sampling frequency in fft analysis.

fftsampling frequency

Dear Friends, i have daily(one day one value) data for 5 years. How to give the time (sampling frequency) in fft analysis. Here i attaching the code. Please correct it and give me suggestions. Here attaching the data also (txt), Thanking you
X=xlsread('data.xlsx');
xfft = fft(X(:,2));
n=length('enter the length of fft');
DT = X(2,1)-X(1,1);
% sampling frequency
Fs = 1/DT;
DF = Fs/size(X,1);
freq = 0:DF:Fs/2;
xfft = xfft(1:length(xfft)/2+1);
plot(freq,abs(xdft));
xlabel ('Frequency');
ylabel ('power');
title('S-fft')

Best Answer

FFT algorithm doesn't care what the sampling rate is; your rate is 1/Day so that's the frequency. You can convert to any other frequency you desire of per year by dividing by average of 365.25 day/year or to conversely to hourly or whatever by multiplying by the appropriate scaling factor in the computation of dF for Fs.
See the example at
doc fft
for the way to compute the sampling frequency and normalize to the length of the FFT vis a vis the sample length; note that the computation is totally independent of the actual x value; the frequency axis is purely dependent upon the units you choose.