Question: MATLAB Problem 1: A car, initially at rest, accelerates in x direction with the following expression a(t) = 5sech tanh( ). where a is acceleration
Problem 1: A car, initially at rest, accelerates in x direction with the following expression a(t) = 5sech tanh( ). where a is acceleration and t is time. In this exercise, you are to explore the motion of the car numerically using Euler method. The motion is described by the following differential equations: dt dr dt 20 where u is velocity. Using Euler method and capital letters to denote the approximation the equations can be Tn T. where subscript n denotes variables at current time, subscript n+1 denotes variables at a time that is ahead. Write function car.m to numerically solve for the motion of the car. The function should have the following header: function T. x. U] car (Ti dt The inputs are total traveling time Tf and the time step dt. The outputs vectors T, X and U are the time, distance and velocity of the car, respectively, Give the function a description (a) Set pla=evalc('help car') Set the answers to plb, plc, and pld, respectively. Use 5-second time step. velocity into ple, plf, and plg, respectively (b,c,d) Use function car to get the time, distance, and velocity of the car for T, = 60 s. (e,f.g) Repeat the step above with 1-second time step. Put the time, distance, and (h) Create figure 1. Use function subploto lude 2 panels with one on top of the other. Plot distance versus time in the top panel. The top panel should include 2 curves the 5-second time step in parts (b,c and the 1-second time step in parts (e,f). Plot velocity versus time in the bottom panel. The bottom panel should also include 2 curves: the 5- second time step in parts (b.d) and the 1-second time step in parts (e.g). Use different solid symbols (no line) for the curves. Set plh See figure 1' An 6.point eztra credit will be given if you include the analytical solution of the distance and velocity in the figure. Use solid line to denote the solution which can be obtained by integrating the differential equations as you had done in your math/physics class
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
