The following table shows the acceleration (m/s2) of a vehicle over time. Calculate the velocity (m/s) and the displacement (m) of the vehicle at t=1, 2,….,10 s using trapezoidal rule.
Time (s) Acceleration (m/s2)
0 0
1 1
2 3
3 5
4 8
5 10
6 13
7 15
8 18
9 21
10 25
% acceleleration (m/s^2):
a = [0, 1, 3, 5, 8, 10, 13, 15, 18, 21, 25];
n = length(a);
% velocity (m/s):
v = zeros(1, n);
for i=2:n
v(i) = v(i-1) + (a(i-1) + a(i))/2;
end
disp(v)
% displacement (m):
d = zeros(1, n);
for i=2:n
d(i) = d(i-1) + (v(i-1) + v(i))/2;
end
disp(d)
Comments
Leave a comment