space craft trajectory (earth to moon)
5 views (last 30 days)
Show older comments
Hello! So I am trying to simulate ths trajectory of a spacecraft that goes from earth to the moon, the problem is that there's a variable in the motion equation (sun an moon postition) that mus change fo a certain time, to be more clear this is a simulation for a tspan = 3days, so the moon and sun position must change durring day 1, 2 and 3. But I am confused on how to do so, knowing that I am using ode45 to find the solution of the motion equation.
I did an if statment, but it did not give the results I wanted
2 Comments
John D'Errico
on 5 May 2023
You did an if statement and it did not give the results you wanted. So write better code, but first, understand the problem you are trying to model. There is no question in this about MATLAB. If there was, you would have shown what you tried, and asked for help in fixing it.
I would start with a simple three body problem, solving for the relative positions of the earth and moon in the gravitational field of the sun. (Actually, long term predictions for even a three body system can be difficult to predict, but this is not long term in context.)
Having done that, AND having shown to yourself that your model has predictive capability, then now I might throw in a 4th body, the space craft. Since it is so small relative to the other terms, the spacecraft will have no impact on the behavior of the eart, sun, moon system. They will impact it, of course. So the inital 3 body equations do not change at all. You are only adding another equation in effect.
There is no if statement to worry about here, except for possibly deciding when the craft crashes into the moon. And even that does not require an if statement, but an ODE event, so when the position of the craft with the surface of the moon is less then the radius of the moon..
Answers (0)
See Also
Categories
Find more on Gravitation, Cosmology & Astrophysics in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!