51 ビュー (過去 30 日間)
古いコメントを表示
Johann Vormadal 2024 年 5 月 23 日 15:10
コメント済み: Johann Vormadal 約6時間 前
- Ch5 data.mat
- Figure.fig
MATLAB Online で開く
I have a (n x 1) vector containing acceleration data from a sensor and I am trying to obtain the displacement by:
- performing an FFT
- Convert acceleration to displacement in the frequency domain by dividing by -omega^2
- performing an IFFT to get back to the time domain.
The idea is to make a conversion which doesn't result in any Zero-drift, but all my attempts so far result in the oscillation being superimposed on a very low frequency wave (See figure attached), and I can't tell where this low frequency oscillation is coming from. The result should be a near sinusoidal wave centred around zero.
Below is a (slightly modified) snippet from my code. The sensor data (Ch5) is attached as a .mat file.
Tinterval = 0.000625;
Length = length(Ch5);
SamplingFrequency = 1/Tinterval;
Frequency = SamplingFrequency*(0:Length-1)/Length;
Omega = 2*pi*Frequency;
ConversionFactor = -(Omega.^2).';
ConversionFactor(1,:) = 1; %To avoid dividing by zero
% Base Data
RawData = Ch5;
Data = RawData - mean(RawData);
FourierTransform = fft(Data);
Y_accel_base = ifft(FourierTransform).';
dY_base = abs(ifft(FourierTransform./ConversionFactor)).';
2 件のコメント なしを表示なしを非表示
なしを表示なしを非表示
Mathieu NOE 2024 年 5 月 27 日 9:57
このコメントへの直接リンク
https://jp.mathworks.com/matlabcentral/answers/2121921-converting-acceleration-data-to-displacement-data-using-fft-results-in-zero-drift#comment_3172816
hello
doing it by fft/ifft is a requirement or just an idea ?
also notice that the raw data is not zero mean, so you're going to have drift on first integration then a parabolic trend on the 2nd integration
Johann Vormadal 2024 年 5 月 28 日 7:46
このコメントへの直接リンク
https://jp.mathworks.com/matlabcentral/answers/2121921-converting-acceleration-data-to-displacement-data-using-fft-results-in-zero-drift#comment_3173656
Hi,
In my code I remove my DC offset before applying the fft.
The requirement is to have zero drift. the fft/ifft seems to be the best way to acheive this (in theory).
サインインしてコメントする。
サインインしてこの質問に回答する。
回答 (1 件)
Mathieu NOE 2024 年 5 月 27 日 10:20
MATLAB Online で開く
- Ch5 data.mat
FYI, a very simple time domain approach - assuming we don't care about the DC values , only the dynamic portion of the data is of interest
results may be even refined by adding some high pass filtering if you really need it
load('Ch5 data.mat')
dt = 0.000625;
fs = 1/dt; % sampling rate
acc = Ch5;
samples = numel(acc);
t = (0:samples-1)*dt;
% remove DC value
acc = acc - mean(acc);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
velocity = cumtrapz(dt,acc);
velocity = detrend(velocity); % baseline correction
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
disp = cumtrapz(dt,velocity);
disp = detrend(disp); % baseline correction
%
figure(1)
subplot(311),plot(t,acc);
title('accel'); ylabel('m/s²');xlabel('time (s)');
subplot(312),plot(t,velocity);
title('velocity'); ylabel('m/s');xlabel('time (s)');
subplot(313),plot(t,disp);
title('disp'); ylabel('m');xlabel('time (s)');
5 件のコメント 3 件の古いコメントを表示3 件の古いコメントを非表示
3 件の古いコメントを表示3 件の古いコメントを非表示
Johann Vormadal 2024 年 5 月 28 日 7:56
このコメントへの直接リンク
https://jp.mathworks.com/matlabcentral/answers/2121921-converting-acceleration-data-to-displacement-data-using-fft-results-in-zero-drift#comment_3173671
編集済み: Johann Vormadal 2024 年 5 月 28 日 9:50
Thank you for the response
I was not aware of those functions, but it seems there is still a bit of zero drift in your displacement result, which I cannot have.
Since my displacement result doesn't even reach zero it seems to me like I am applying the fft/ifft wrong. It shouldn't be possible for the ifft to produce a constant zero offset when the 0hz bucket is emtpy.
Mathieu NOE 2024 年 5 月 28 日 12:02
このコメントへの直接リンク
https://jp.mathworks.com/matlabcentral/answers/2121921-converting-acceleration-data-to-displacement-data-using-fft-results-in-zero-drift#comment_3173916
MATLAB Online で開く
- Ch5 data.mat
a slight improvement , as you can "play" with the order of detrending ...(constant, or nth order polynomial)
load('Ch5 data.mat')
dt = 0.000625;
fs = 1/dt; % sampling rate
acc = Ch5;
samples = numel(acc);
t = (0:samples-1)*dt;
% remove DC value
acc = detrend(acc,0); % baseline correction
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
velocity = cumtrapz(dt,acc);
velocity = detrend(velocity,1); % baseline correction
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
disp = cumtrapz(dt,velocity);
disp = detrend(disp,3); % baseline correction
%
figure(1)
subplot(311),plot(t,acc);
title('accel'); ylabel('m/s²');xlabel('time (s)');
subplot(312),plot(t,velocity);
title('velocity'); ylabel('m/s');xlabel('time (s)');
subplot(313),plot(t,disp);
title('disp'); ylabel('m');xlabel('time (s)');
Johann Vormadal 約7時間 前
このコメントへの直接リンク
https://jp.mathworks.com/matlabcentral/answers/2121921-converting-acceleration-data-to-displacement-data-using-fft-results-in-zero-drift#comment_3175111
I should have mentioned in my original post that I will need to run this script for many samples, so I need a solution that doesn't require any manual fiddling.
I also notice that the phasing in the 'disp' graph is slightly misaligned towards the end with the phasing on the 'accel' graph.
I wonder if cropping the raw data to a whole number of cycles would improve the quality of the results.
Mathieu NOE 約7時間 前
このコメントへの直接リンク
https://jp.mathworks.com/matlabcentral/answers/2121921-converting-acceleration-data-to-displacement-data-using-fft-results-in-zero-drift#comment_3175141
have to try a few other options , like :
Finding the velocity from displacement - MATLAB Answers - MATLAB Central (mathworks.com)
Converting acceleration to displacements records - File Exchange - MATLAB Central (mathworks.com)
there are probably more ...
Johann Vormadal 約6時間 前
このコメントへの直接リンク
https://jp.mathworks.com/matlabcentral/answers/2121921-converting-acceleration-data-to-displacement-data-using-fft-results-in-zero-drift#comment_3175176
Thank you for those links!
Those also use the fft method, but their code is slightly different and much more elegant. I will try and emulate them, and see if it solves my problem.
サインインしてコメントする。
サインインしてこの質問に回答する。
参考
カテゴリ
MATLABMathematicsFourier Analysis and Filtering
Help Center および File Exchange で Fourier Analysis and Filtering についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
エラーが発生しました
ページに変更が加えられたため、アクションを完了できません。ページを再度読み込み、更新された状態を確認してください。
Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
南北アメリカ
- América Latina (Español)
- Canada (English)
- United States (English)
ヨーロッパ
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- Deutsch
- English
- Français
- United Kingdom(English)
アジア太平洋地域
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)
最寄りの営業オフィスへのお問い合わせ