How to extract correct FFT?

4 次查看(过去 30 天)
Samuel
Samuel 2012-4-23
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

采纳的回答

Dr. Seis
Dr. Seis 2012-4-23
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 个评论
Samuel
Samuel 2012-4-23
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 2012-4-23
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?

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Fourier Analysis and Filtering 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by