Write a program that that computes and plots the acceleration profile of racecar. The racecar's acceleration can be approximated as piecewise linear.
a(t)=kt+c
where t is time in seconds, k is the slope of the acceleration profile, and c is the y-intercept of the acceleration profile. The constants change depending on how the accelerator or brake of the vehicle are pressed. They are defined by Equations 2 and 3, with the specified time intervals.
k={ 6m/s^2 0s<=t<=3s
0m/s^2. 3s<=t<=5s
10m/s^2. 5s<=t<=7s
-3.1m/s^2 7s<=t<=10s}
c={ 0m/s^2 0s<=t<=3s
6m/s^2. 3s<=t<=5s
0m/s^2. 5s<=t<=7s
-10.8m/s^2 7s<=t<=10s}
Using the given information, write a script that specifically: Uses a for-loop to compute the time variable and the acceleration variable. Uses an if-elseif-else statement nested inside the for-loop to control which constants are used for the acceleration function. Uses an increment of delta t =- 0.125 seconds between successive points in the time array. • Plots the acceleration profile of the racecar versus tune with a fully documented plot.
Output must be:
An array called "t" for time An array called "A" for acceleration.