I'm trying to find displacement from acceleration datas
조회 수: 7 (최근 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!