signal-processing - 通过 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')
请你再检查一遍好吗?我的变量定义如下:
s
:测量的“G”值。共有 3395 个测量值。t
:时间。每个值在 0.001s 后记录,共 3.395s。
解决方案
你说的最高点是正常的。在没有频率截止的情况下,傅立叶变换的开始(最接近零)将始终具有最大的频谱能量,因为它正在解析趋向于零的采样率,正如您可以想象的那样,在时间序列中会有大量的表示。显然 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')
推荐阅读
- reactjs - 如何在 React 中的 onblur 事件后检查组件是否已被单击
- java - Maven 无法使用 eclipse 解决 Jacob 依赖关系
- java - 点燃持久化集合:找不到具有紧凑页脚的对象的元数据
- json - 如何在 React.js 中从 json 给出相对本地路径?
- google-chrome - Chrome 扩展程序截取的屏幕截图 - 隐私风险?
- javascript - 使用其他数据javascript将分号分隔的值拆分为多行
- html - 如何将容器放置在具有自身溢出的固定位置?
- sql - 在 SSIS csv 导出中去除日期/时间分隔符
- javascript - 如何将缓动函数应用于此跳波动画
- windows - Docker 透明网络和端口映射