- Write down the differential equations of motion (should be a 2nd order 3-element vector differential equation)
- Convert this to a set of six 1st order differential equations (see ode45( ) doc for example of this)
- Write a derivative function that takes (t,y) as input (t=time,y=6-element state vector) and outputs 6-element derivative vector)
- Pass derivative function handle, time span, and initial conditions to ode45( )
- Compare end result with expected result
Change of position of velocity vectors and time interval between the change
9 views (last 30 days)
James Tursa on 27 Sep 2022
Edited: James Tursa on 27 Sep 2022
Looks like an orbit problem. Around the Earth, I presume? You will not be using the Symbolic Toolbox for this assignment. You will be doing numerical integration. You need to do the following:
The 2nd order 3-element vector differential equation should look like = some function of and μ
The 6-element state vector to use would be  (i.e., stack position and velocity  ).
The derivative of this 6-element state vector is simply , or .
In fact, the derivative function is pretty simple and would look something like this:
function ydot = orbit_derivative(t,y)
mu = appropriate value for the planet (units need to be consistent with t and y)
r = y(1:3); % the 3-element position vector
rdot = y(4:6); % the 3-element velocity vector
rdotdot = your expression for the 2nd derivative in terms of r and mu (you fill this in)
ydot = [rdot;rdotdot]; % the 6-element derivative vector to return
The function handle you would pass to ode45( ) would be @orbit_derivative
Alternatively you could pass in mu as an extra argument to the derivative function, in which case the function handle you would pass to ode45( ) would be @(t,y)orbit_derivative(t,y,mu)
For the true anomaly part of this assignment, you will need code that can calculate classical orbital elements from a state vector.
Make an effort at this, and post specific questions about your code if you run into problems. The above assumes you can use the MATLAB supplied numerical integration functions such as ode45( ). If that is not the case, then you will need to write your own solver using a method such as Euler, Modified Euler, or RK4. But in either case, you would still use the exact same derivative function outlined above.