Modeling Motion of Earth with Matlab using ODE45

In summary, the conversation discussed modeling the motion of the Earth around the Sun using ode45 and an euler-cromer scheme. The speaker encountered errors when trying to use the same equation for acceleration in both methods, and struggled with understanding the inputs for the ODE solver. The homework equations involved using the vector form of acceleration for a mass due to another mass. The attempted solution included a function with only 2 degrees of freedom, but it was pointed out that it needed to be able to take in a vector of length 4.
  • #1
PhysSci1
1
0

Homework Statement


So I am trying to model the motion of the Earth around the Sun using ode45. I modeled this using an euler-cromer scheme, but I would like to get familiar with using a solver. I wrote the code for an Euler-cromer and it worked just fine. However, when I try to use the same equation that I derived for acceleration in the Euler scheme in the ODE, I get errors. I think it is because I am not quite sure how the inputs work for ODE. I have tried to figure it out by looking through resources on the internet, but I just can't figure it out.

Homework Equations


The equation I used was the vector form of acceleration of a mass due to another mass. This equation in MATLAB is

-G * Msun * R / (sum(R.*R)^(3/2)) where R = Psun - Current position (as vectors, [x y] - [x y]).

The Attempt at a Solution



This is my attempt, which provides this error:

In an assignment A(:) = B, the number of elements in A and B
must be the same.

Error in orbit (line 10)
dp(2) = -G * Msun * R / (sum(R.*R)^(3/2));

My function:
G = 6.673E-11/(1000^3);

Psun = [0 0];

Msun=1.988e30;

R = Psun - P(2);

M = 1.98892E30;

dp = zeros(2,2);

dp(1)= P(2);

dp(2) = -G * Msun * R / (sum(R.*R)^(3/2));

How I call it:

[T,Y] = ode45(@Orbit,[0, 3.15581e7],[1.5e8, 0, 0, 29.75]);
 
Physics news on Phys.org
  • #2
The problem you have has for degrees of freedom: ##x, y, \dot{x}, \dot{y}##. Your function is set up with only 2. It need to be able to take in a vector y of length 4, containing the 4 dof, and return a vector y' of length 4 also.
 

1. What is ODE45 and how does it relate to modeling motion of Earth with Matlab?

ODE45 is a numerical integration function in Matlab that solves ordinary differential equations (ODEs). In the context of modeling motion of Earth, ODE45 can be used to solve the equations of motion that describe the Earth's movement around the sun.

2. Why is Matlab used to model motion of Earth instead of other programming languages?

Matlab is a popular choice for modeling scientific and mathematical problems because it has built-in functions and tools specifically designed for these applications. It also has a user-friendly interface and efficient computational capabilities, making it well-suited for complex simulations like modeling the motion of Earth.

3. What are the key parameters and variables needed for modeling motion of Earth with Matlab and ODE45?

The key parameters and variables needed for modeling motion of Earth with Matlab and ODE45 include the Earth's mass, the sun's mass, the distance between the two bodies, the initial position and velocity of the Earth, and the gravitational constant. Other factors such as the Earth's rotation and the effects of other planets can also be included in the model.

4. Can the model accurately predict the motion of Earth over long periods of time?

Yes, the model can accurately predict the motion of Earth over long periods of time as long as the initial conditions and parameters are accurately inputted. However, the model may become less accurate over very long time frames due to the changing nature of the Earth's orbit and the influence of other celestial bodies.

5. Can this model be used to study the motion of other planets in the solar system?

Yes, the same principles and techniques used to model the motion of Earth with Matlab and ODE45 can be applied to other planets in the solar system. However, the parameters and initial conditions would need to be adjusted to reflect the unique characteristics of each planet.

Similar threads

  • Engineering and Comp Sci Homework Help
Replies
1
Views
881
  • Engineering and Comp Sci Homework Help
Replies
2
Views
826
  • Introductory Physics Homework Help
Replies
5
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
6
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
10
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
5
Views
5K
  • Engineering and Comp Sci Homework Help
Replies
3
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
2
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
8
Views
1K
Back
Top