I'm trying to find displacement from acceleration datas
13 ビュー (過去 30 日間)
古いコメントを表示
Hi, I would like to ask a question about an issue that I'm facing. I'm trying to find the displacement of a vibrating object by integrating some acceleration datas I acquired using a piezoelectric accelerometer. I tried integrating them by using the cumtrapz function twice but the displacement datas that I obtain are pretty weird and very far from the real phenomenon. I'm uploading the two graphs of the acquired acceleration and the displacement to make my issue more clear. Is there something that I'm missing? Thank you in advance for your help.
0 件のコメント
回答 (1 件)
Star Strider
2024 年 4 月 16 日
Your original ac celeration data have a trend, and you are integrating the trend. Use the detrend function tto remove it (alternatively, use a highpass filter), and the data appears to be much more reasonable.
Try this —
files = dir('*.fig');
for k = 1:numel(files)
fn = files(k).name
F{k} = openfig(fn);
hl{k} = findobj(F{k}, 'Type','line');
x{k,:} = hl{k}.XData;
y{k,:} = hl{k}.YData;
B = [x{k}; ones(size(x{k}))].' \ y{k}.' % Detect Linear Trend
end
format longG
xstats = [mean(diff(x{1})); std(diff(x{1}))]
format short
[FTs1,Fv] = FFT1(y{1},x{1});
figure
plot(Fv, abs(FTs1)*2)
grid
xlabel('Frequency')
ylabel('Magnitude')
xlim([0 1E+3])
ydt = detrend(y{1}, 1);
vel = cumtrapz(x{1}, ydt);
dspl = cumtrapz(x{1}, vel);
figure
plot(x{1}, vel, 'DisplayName','Velocity')
hold on
plot(x{1}, dspl, 'DisplayName','Displacement')
hold off
grid
xlabel('Time')
ylabel('Amplitude')
legend('Location','best')
function [FTs1,Fv] = FFT1(s,t)
t = t(:);
L = numel(t);
if size(s,2) == L
s = s.';
end
Fs = 1/mean(diff(t));
Fn = Fs/2;
NFFT = 2^nextpow2(L);
FTs = fft((s - mean(s)) .* hann(L).*ones(1,size(s,2)), NFFT)/sum(hann(L));
Fv = linspace(0, 1, NFFT/2+1)*Fn;
Iv = 1:numel(Fv);
FTs1 = FTs(Iv,:);
end
There is a small amount of noise in the data, however it does not appear to affect the result.
.
2 件のコメント
Star Strider
2024 年 4 月 17 日
My pleasure!
My code solves the problem of integrating the offset and trend, and that is all you requested.
Your data are your data, so you may need to re-scale or re-calibrate your initial measurements. I have no control over that.
参考
カテゴリ
Help Center および File Exchange で Vibration Analysis についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!