NaikD
Mechanical
- Nov 23, 2002
- 48
Hi,
I am getting wrong results and hence trying to figure out if I am computing FFT from time domain data right.
Here is the code for matlab (MATLAB 7.5.0; R2007b).
AllData.dat file contains time in first column and X moment in the 5th column.
load AllData.dat;
Time = AllData
,1);
Mx = AllData
,5);
% Define time step and sampling frequency
Ts=Time(2)-Time(1); % Time Step (sec)
fs=1/Ts; %frequency
% X Axis Moment (Mx) FFT Plots
Mx_fft = fft(Mx);
Mx_fft = abs(Mx_fft)/(length(Time)/2);
FHz_fft = [0
length(Time)-1)]*(1/(Ts*length(Time))); % Cycles per seconds
%
figure;
subplot(1,1,1)
loglog(FHz_fft,Mx_fft,'k',[0.03906 0.159 5.30 1000],[0.003 0.003 0.1 0.1],'r');
grid on;
%Raw moment FFT plot
xlabel('Frequency (Hz)');
ylabel('Moment Mx (N-m)');
title('X Axis Moment Mx FFT');
grid on;
print -djpeg Mx-fft;
I know this is elementary for some of you. Thanks in advance.
Appreciate your help.
- Dipak
I am getting wrong results and hence trying to figure out if I am computing FFT from time domain data right.
Here is the code for matlab (MATLAB 7.5.0; R2007b).
AllData.dat file contains time in first column and X moment in the 5th column.
load AllData.dat;
Time = AllData
Mx = AllData
% Define time step and sampling frequency
Ts=Time(2)-Time(1); % Time Step (sec)
fs=1/Ts; %frequency
% X Axis Moment (Mx) FFT Plots
Mx_fft = fft(Mx);
Mx_fft = abs(Mx_fft)/(length(Time)/2);
FHz_fft = [0
%
figure;
subplot(1,1,1)
loglog(FHz_fft,Mx_fft,'k',[0.03906 0.159 5.30 1000],[0.003 0.003 0.1 0.1],'r');
grid on;
%Raw moment FFT plot
xlabel('Frequency (Hz)');
ylabel('Moment Mx (N-m)');
title('X Axis Moment Mx FFT');
grid on;
print -djpeg Mx-fft;
I know this is elementary for some of you. Thanks in advance.
Appreciate your help.
- Dipak