First Step
Posted: Wed Oct 25, 2017 11:26 am
Due at the beginning of class on Friday, November 3, 2017. No extensions and strict deadline. The Miata didn't get to where it is today by its engineers being late. If you can't get to class before it starts, have a trustworthy friend submit your report.
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:
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():
The whole part
is the anonymous function. Without the very first part in front of carrhs it won't work. You should think of the whole part as like "@ex1rhs" like we've done in class a lot of times.
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)