Change of position of velocity vectors and time interval between the change
5 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
Steven Lord
il 26 Set 2022
You should ask whomever gave you this assignment (your professor or teaching assistant, I assume?) for more information.
Risposte (1)
James Tursa
il 27 Set 2022
Modificato: James Tursa
il 27 Set 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:
- 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 μ
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1137195/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1137185/image.png)
The 6-element state vector to use would be [
] (i.e., stack position and velocity [
] ).
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1137190/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1137200/image.png)
The derivative of this 6-element state vector is simply [
], or [
].
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1137240/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1137210/image.png)
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.
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!