通过 Octave 中的快速傅立叶变换评估汽车振动

Car vibration evaluated by Fast Fourier Transform in Octave

我必须评估汽车的振动。对于这个试验,我使用了加速度计。收集的数据取决于时间。

我需要通过 FFT 将数据从时域转换到频域。不幸的是,我对编码和 FTT 不是很熟悉,但是我找到并使用了下面的代码。

令我感到奇怪的是,最大高点的频率为 0Hz。请看附图。 无论如何,有没有办法让图表更明显?例如,在 x 轴上剪切一个系列,只显示 200Hz 以下的数据。

clc
A=xlsread('50_dirt_road.xlsx');
t=A(:,9);
s=A(:,8);
Ts = mean(diff(t));                                     % Sampling Interval
Fs = 1/Ts;                                              % Sampling Frequency
Fn = Fs/2;                                              % Nyquist Frequency
L = numel(t);                                           % Signal Length
sm = s - mean(s);                                       % Mean-Corrected Signal (Eliminates 0 Hz Offset)
FTs = fft(sm)/L;                                        % Fourier Transform
Fv = linspace(0, 1, fix(L/2)+1)*Fn;                     % Frequency Vector
Iv = 1:numel(Fv);                                       % Index Vector
[MaxV,idx] = max(abs(FTs(Iv))*2);                       % Maximum V & Index
Freq = Fv(idx);                                         % Frequency Of Maximum V
figure
plot(Fv, abs(FTs(Iv))*2)
grid
text(Freq, MaxV, sprintf('\leftarrow %.4f G, %.0f Hz', MaxV, Freq), 'HorizontalAlignment','left')
xlabel('Frequency (Hz)')
ylabel('Amplitude')

请您仔细检查一下好吗?我的变量定义如下:

你说的最高点是正常的。在没有频率截止的情况下,傅里叶变换的开始(最接近零)将始终具有最大的频谱能量,因为它正在解析趋向于零的采样率,正如您可以想象的那样,这在时间序列中会有大量的表示。显然 0 赫兹是不可能的,因此您应该选择一个在汽车振动领域有意义的下限频率。所以我推荐一个带通滤波器,一个做正向和反向滤波(filt filt)的滤波器来保留原始时间序列,然后 运行 通过这个分析得到的结果。如果需要,我将从巴特沃斯滤波器开始并尝试其他滤波器:

https://octave.sourceforge.io/signal/function/butter.html

编辑:

我用的是t,但是信号是s。这是全部内容:

clc
A=xlsread('50_dirt_road.xlsx');
t=A(:,9);
s=A(:,8);
Ts = mean(diff(t));                                     % Sampling Interval
Fs = 1/Ts;                                              % Sampling Frequency
Fn = Fs/2;                                              % Nyquist Frequency
L = numel(t);                                           % Signal Length

%1st order butterworth filter with a band pass of 1hz to 200hz in radians
%forward and reverse filtered
[b,a] = butter(1, [1/(L/2), 200/(L/2)]);
filtered_s = filtfilt(b,a,s);

sm = filtered_s - mean(filtered_s);                     % Mean-Corrected Signal (Eliminates 0 Hz Offset)
FTs = fft(sm)/L;                                        % Fourier Transform
Fv = linspace(0, 1, fix(L/2)+1)*Fn;                     % Frequency Vector
Iv = 1:numel(Fv);                                       % Index Vector
[MaxV,idx] = max(abs(FTs(Iv))*2);                       % Maximum V & Index
Freq = Fv(idx);                                         % Frequency Of Maximum V
figure
plot(Fv, abs(FTs(Iv))*2)
grid
text(Freq, MaxV, sprintf('\leftarrow %.4f G, %.0f Hz', MaxV, Freq), 'HorizontalAlignment','left')
xlabel('Frequency (Hz)')
ylabel('Amplitude')

最后编辑:

好的,当我认为您想要做的只是限制 FFT 的轴时,我想我已经向您介绍了滤波的世界。上面带通滤波器的参数相同,1hz 和 200hz。上面的代码应该可以工作,但下面的代码可能是您最初要查找的代码:

clc
A=xlsread('50_dirt_road.xlsx');
t=A(:,9);
s=A(:,8);
Ts = mean(diff(t));                                     % Sampling Interval
Fs = 1/Ts;                                              % Sampling Frequency
Fn = Fs/2;                                              % Nyquist Frequency
L = numel(t);                                           % Signal Length

sm = s - mean(s);                     % Mean-Corrected Signal (Eliminates 0 Hz Offset)
FTs = fft(sm)/L;                                        % Fourier Transform
Fv = linspace(0, 1, fix(L/2)+1)*Fn;                     % Frequency Vector
freqMask = (Fv > 1) & (Fv < 200);
Fv = Fv(freqMask);
FTs = FTs(freqMask);
Iv = 1:numel(Fv);                                       % Index Vector
[MaxV,idx] = max(abs(FTs(Iv))*2);                       % Maximum V & Index
Freq = Fv(idx);                                         % Frequency Of Maximum V
figure
plot(Fv, abs(FTs(Iv))*2)
grid
text(Freq, MaxV, sprintf('\leftarrow %.4f G, %.0f Hz', MaxV, Freq), 'HorizontalAlignment','left')
xlabel('Frequency (Hz)')
ylabel('Amplitude')