MATLAB Answers

Calculate acceleration from velocity and time fron excel

303 views (last 30 days)
Wayne
Wayne on 20 Apr 2020
Commented: Fabio Freschi on 20 Apr 2020
Hi I have an excel sheet with Velocity and Time columns for each step. I need help to input this excel sheet and add a 3rd column with acceleration data.
For example: (Input)
Time (s) Velocity (m/s)
0 50
1 51
2... 52...
For example: (Required Output)
T (s) V (m/s) Acceleration (dV/T)(m/s^2)
0 50 (50-0)/0
1 51 (51-50)/1
2... 52... (52-51)/2
I've used the following to read the Excel
filename='Example.xlsx';
[filepath,name,ext] = fileparts(filename) ;
data = readtable(filename);
N = length(data.t);

  0 Comments

Sign in to comment.

Accepted Answer

Fabio Freschi
Fabio Freschi on 20 Apr 2020
Edited: Fabio Freschi on 20 Apr 2020
acceleration = diff(data.Velocity)./diff(data.Time);
Note that this vector has one entry less than the original ones, so you may be interested in creating a new vector of time at the mid point of each time interval
tt = (data.Time(1:end-1)+data.Time(2:end))/2;

  5 Comments

Show 2 older comments
Fabio Freschi
Fabio Freschi on 20 Apr 2020
This line
Acceleration = diff(Velocity)/Time;
is mistyped. Use
Acceleration = diff(Velocity)./diff(Time);
for incremental element-wise division
Fabio Freschi
Fabio Freschi on 20 Apr 2020
acceleration is the time derivative of velocity. diff(Velocity)./diff(Time) is the derivative in a discrete setting

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!