Usman Akbar NA Open Ended Lab
Usman Akbar NA Open Ended Lab
An automobile is moving in a straight line at variable velocity. The velocity of the automobile is
measured at different time intervals, but the time intervals are not equal.
The students are given a table of data that contains the time and acceleration measurements. The
students need to generate the velocity vs time and displacement vs time graphs for the automobile
using the data provided.
Data:
1. Use the data provided to generate the velocity vs time and displacement vs time graphs for the
automobile using an appropriate numerical integration method.
2. Use MATLAB to write a script that reads the data from the table, performs the integration, and
generates the velocity vs time and displacement vs time graphs.
% Trapezoidal integration
for i = 2:length(time)
% Calculate velocity using trapezoidal rule
delta_t = time(i) - time(i-1);
avg_acceleration = (acceleration(i) + acceleration(i-1)) / 2;
velocity(i) = velocity(i-1) + avg_acceleration * delta_t;
3)