# I try to find the air under the curve of this signal

26 views (last 30 days)
Kober Florian on 18 Apr 2021 at 10:16
Commented: Kober Florian on 18 Apr 2021 at 13:22
Hello everyone,
For a project, I made an acquisition of accelleration data with a sensor. I would like to find the distance from these acceleration data for that I focus on the z axis.
datacq(:,1)=datacq(:,1)-datacq(1,1)
t=datacq(:,1)*10^-3
%accelerationx=abs(datacq(:,2))
%accelerationy=abs(datacq(:,3))
accelerationz=abs(datacq(:,4))
figure
% subplot(2,1,1)
% plot(t,accelerationx)
% subplot(2,1,2)
% plot(t,accelerationy)
% subplot(2,1,3)
plot(t,accelerationz)
hold on
% processing
ax=datacq(:,4);
ax=abs(ax);
figure
plot(ax)
hold on
for i=1:250
vx(i)=(trapz(ax(1:i))*t(2));
%Ret(i) = vx(i+1)-vx(i);
end
plot(vx)
distance = trapz(vx(1:251)*t(2))
I did this but it's not working, it's false. Could you help me please?
Respectfully FK

Alan Stevens on 18 Apr 2021 at 13:11
Like this?
datacq(:,1)=datacq(:,1)-datacq(1,1);
t=datacq(:,1)*10^-3;
accelerationz=abs(datacq(:,4));
figure
plot(t,accelerationz)
% processing
dt = t(2)-t(1);
ax=datacq(:,4);
%ax=abs(ax);
vx = cumtrapz(ax)*dt;
dx = cumtrapz(vx)*dt;
figure
subplot(3,1,1)
plot(t,ax),grid
ylabel('ax')
subplot(3,1,2)
plot(t,vx),grid
ylabel('vx')
subplot(3,1,3)
plot(t,dx),grid
xlabel('t'), ylabel('dx')
Kober Florian on 18 Apr 2021 at 13:22
Oh with cumtrapz. Perfect, thank you very much.