# MATLAB: FFT of discrete time domain data

fft

Dear all,
I have vibration data from a setup in time domain. I need to convert into frequency domain,for which i have coded as below
n=length(data);ts=t(2)-t(1);p=abs(fft(data));p=p(1:n/2).^2;freq=[1:n/2]/ts;figure(2)plot(freq,p)
But the frequency components obtained in the plot, are not matching with actual ones,which i think the error in frequency axis of fft plot.Is any normalisation of axis needed . how to rectify this error .
Regards.

n = length(data); Ts = t(2)-t(1); % sample timeFs = 1/Ts; % sampling frequencyNFFT = 2^nextpow2(n); % Next power of 2 from length of dataY = fft(data,NFFT)/n;f = Fs/2*linspace(0,1,NFFT/2+1);% Plot single-sided amplitude spectrum.plot(f,2*abs(Y(1:NFFT/2+1))) title('Single-Sided Amplitude Spectrum of y(t)')xlabel('Frequency (Hz)')ylabel('|Y(f)|')