Change of position of velocity vectors and time interval between the change
6 次查看(过去 30 天)
显示 更早的评论
How would I symbolically write a MATLAB code that can find:
a) Position and Velocity vectors at a later time given initial position and velocity
b) The interval (time) between the initial and final values
4 个评论
Steven Lord
2022-9-26
You should ask whomever gave you this assignment (your professor or teaching assistant, I assume?) for more information.
回答(1 个)
James Tursa
2022-9-27
编辑:James Tursa
2022-9-27
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:
- 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
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
end
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.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Symbolic Math Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!