I'm trying to find displacement from acceleration datas
13 views (last 30 days)
Show older comments
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 Comments
Answers (1)
Star Strider
on 16 Apr 2024
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 Comments
Star Strider
on 17 Apr 2024
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.
See Also
Categories
Find more on Vibration Analysis in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!