# Integrate acceleration to velocity and displacement

374 views (last 30 days)

Show older comments

##### 0 Comments

### Answers (4)

John D'Errico
on 25 Mar 2016

Edited: John D'Errico
on 25 Mar 2016

It looks close to good to me. Why do YOU think there is a problem?

Hint: Read the help for the tools you will use. In this case, cumtrapz.

When there are two arguments to cumtrapz, they should be in the order cumtrapz(x,y). Again, from the help, it shows this:

Z = cumtrapz(Y)

Z = cumtrapz(X,Y)

With only one argument, so an implicit X step of 1, you just pass in Y. With two arguments, i.e., acceleration and time, they must go in the proper order.

So, if you will integrate acceleration over time,

velocity = cumtrapz(time,acceleration);

Similarly, the second integral must have its arguments in the proper order.

READ THE HELP.

##### 3 Comments

Sebastián Santibáñez Brito
on 4 Apr 2023

Dr. Seis
on 10 Apr 2016

Try using code from my previous post:

##### 1 Comment

Luke Laurence
on 6 Feb 2018

Sumangali Sivakumaran
on 25 Apr 2019

##### 0 Comments

Prasanth Reddy
on 13 Jun 2022

data = csvread('acc.csv',0,1);

t=0:0.05:947*0.05;

ax = data(:,1) ;

vx=cumtrapz(t,ax);

dx=cumtrapz(t,vx);

subplot(1,3,1);

plot(t,ax);

subplot(1,3,2);

plot(t,vx);

subplot(1,3,3);

plot(t,dx);

this code is not working properly and i cant figure out why

##### 0 Comments

### See Also

### Categories

### Community Treasure Hunt

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

Start Hunting!