MATLAB: How to extract correct FFT

fftfrequencyplot

Hello all,
I thank you guys all in advance for your help!
I am currently trying to plot an FFT plot of the strain gauge data I collected from the oscilloscope, and currently have a routine as defined below:
clear all; close all; clc
t = load('T0011.CSV');
time=t(1:125000,1);
gage=t(1:125000,2); % load files and assign to variables
totaltime=1; % total time captured by scope
figure(1)
plot(time,gage);
xlabel('time(s)')
ylabel('signal(volts)')
title('{\bf MTS data}')
legend('gage');
%

%compute frequency
%
fs=length(gage)/(gage(length(time))+abs(time(1)))
m=length(t);
n=m;
% n=pow2(nextpow2(m));
y=fft(gage)/n;
f=(0:n-1)*(fs/n);
figure(2)
semilogx(f(1:n/2),abs(y(1:n/2)));
title('Frequency (Logarithmic x-axis, Linear y-axis)','fontsize',14)
xlabel('Frequency (Hz)')
ylabel('|y(f)|')
legend('gage1');
Alright, the code below gives the bottom two figures: Signal Data http://imageshack.us/photo/my-images/109/fftb.jpg/ FFT Data http://imageshack.us/photo/my-images/833/fft2.jpg/ If you take a look, the first mode natural frequency is around 200 Hz, which is clearly not correct- going through the peak analysis reveals that the dominant frequency is around 40Hz.
I have noticed that even though the function FFT has been developed and made available, going through the different programming causes different frequency plots to come up (with different values), and wanted to make sure that my approach is correct.
Any help and/or advice will be greatly appreciated!
Sam

Best Answer

Just to eliminate a few things, try this:
dt = time(2)-time(1);
Fs = 1/dt;
M = length(gage);
N = pow2(nextpow2(M));
Nyquist = Fs/2;
df = Fs/N;
f = fftshift(-Nyquist:df:Nyquist-df);
Y = fft(gage)*dt; % I would use dt or 1/Fs for normalization
Related Question