Write a Matlab program that computes the height of the car as it drives down the road.

You may use ode45() as long as you do something to validate the answers you get.

Your program should:

- Plot the height of the car and the height of the road along the length of the road.
- Allow you to change the velocity of driving. You may assume the velocity is constant along the 1 km road, but need to be able to check how the car rides at different velocities for different "runs" along the road. In other words, have a "v" variable.
- Allow you to change k and b, but for this first step you will just use the baseline values.

If you use ode45() in Matlab, it needs a function that gives the right hand side of the differential equation. For some reason, it really, really wants that function to be a function of x and t only. But in order for us to compute y and dydt we need to send it other variables too, like wavenos, phi and sk0. The way to deal with this is with an

*anonymous function.*If my right hand side function is called carrhs.m then use the following syntax in ode45():

Code: Select all

`[t z] = ode45(@(t,z) carrhs(t,z,sk0,wavenos,phi,v,m,b,k),[0 timetodrive1km], [icz iczdot])`

Code: Select all

`@(t,x) carrhs(t,x,sk0,wavenos,phi,v,m,b,k)`