space craft trajectory (earth to moon)

조회 수: 18 (최근 30일)
Blob
Blob 2023년 5월 5일
편집: Blob 2023년 5월 5일
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
John D'Errico
John D'Errico 2023년 5월 5일
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..
Blob
Blob 2023년 5월 5일
편집: Blob 2023년 5월 5일
@John D'Errico if you wish to see my code here it is! and no, this is not a homework (if it was I would go directly to my professors), the reason why I am posting my question here, is to unsure that I have an answer from 'an engineer'. That's all, thank you for your help

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Engines & Motors에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by