How to extract correct FFT?

2 views (last 30 days)
Samuel
Samuel on 23 Apr 2012
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

Accepted Answer

Dr. Seis
Dr. Seis on 23 Apr 2012
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
  2 Comments
Samuel
Samuel on 23 Apr 2012
Excellent. Thanks so much for the prompt and accurate solution!
One more question to follow up in plotting it. I went ahead with the following code and made the plot command as shown above. Specifically:
plot(f(1:N/2),abs(Y(1:N/2)));
However, this command gives a straight line at 0 and 0 elsewhere.
The same command in semilogx command gives the correct plot, however.
Should anything be changed to plot it linearly?
thanks again.
sam
Dr. Seis
Dr. Seis on 23 Apr 2012
I can't imagine why that would be... I would think that simply replacing "semilogx" with "plot" wouldn't cause weird behavior. Can you upload another jpg onto imageshack?

Sign in to comment.

More Answers (0)

Categories

Find more on Fourier Analysis and Filtering in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!