MATLAB Answers

For end loop for acceleration

5 views (last 30 days)
Paisley Simpson
Paisley Simpson on 21 Feb 2019
Edited: Omer Yasin Birey on 21 Feb 2019
i have a table of various data, and need to find the acceleration of a car using the time and speed columns, how exactly do i do this please, using a for end loop.

  0 Comments

Sign in to comment.

Answers (1)

Omer Yasin Birey
Omer Yasin Birey on 21 Feb 2019
Edited: Omer Yasin Birey on 21 Feb 2019
I don't know why you want to write the code with for loop but this might work.
time = yourTime;
dt = diff(time)
v = yourSpeed;
dv = diff(v)
a = zeros(length(dv),1);%acceleration
for i = 1:length(time)-1
a(i) = dv(i)./dt(i)
end
But better you use
a= dv./dt;

  0 Comments

Sign in to comment.

Sign in to answer this question.

Tags