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

1 view (last 30 days)
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= load('Acquisition.txt');
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

Accepted Answer

Alan Stevens
Alan Stevens on 18 Apr 2021
Like this?
datacq= load('Acquisition.txt');
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')

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!