danaxmed.blogg.se

Ode45 matlab
Ode45 matlab










  1. #ODE45 MATLAB HOW TO#
  2. #ODE45 MATLAB CODE#

You will need to write your problem such that the unknowns are a single vector, not a matrix. Is there any other computational way to represent the coupling? What is unnecessary from the inputs I have given and why? What would be another more efficient way to address the initial conditions If my mistake is the use of a matrix initial conditions instead of a vector, using a 1 by 20 vector, and adjust the ode form accordingly would be not practical, I think I thought about using a matrix 10 by 2 as initial conditions. The coupling presents in the last equation. NOTE: The orbital period can only be determined for circular and elliptical orbits (E < 0).EDIT: We have a coupled system of 10 ode each. The semi-major axis of the orbit can then be determined:įinally, from the semi-major axis, the orbital period becomes: The total energy is composed of the kinetic and potential energies and remains constant throughout the orbit: Simply knowing R and V at any point in time and the gravitational parameter of the central body, the period of the orbit can be determined.įirst the total energy of the orbit needs to be calculated. How Did I Know How Long to Integrate For? Options = odeset('MaxStep', 5) % Set maximum step size as 5 seconds % Determine Orbital Period, this is just to determine how long to simulate for NOTE: Any variable referenced by an anonymous function that is not an input to the function, must be define before the function within the code.

#ODE45 MATLAB CODE#

For this problem, anonymous functions are an excellent choice to code the state-space equation. Anonymous functions are convenient since they can be written within another script of function, but they can only contain one executable statement. Now Let’s Get Startedįor this problem, the equation of motion for the satellite will be coded as an anonymous function. To understand the input parameters for the ode45 function, type “doc ode45” and “doc odeset” in the MATLAB command window. The ode45 function within MATLAB uses the Dormand-Prince formulation. I recommend that students write their own Runge-Kutta function to better understand this algorithm prior to adopting that MATLAB internal function. For this problem, we will use the ode45 solver which uses a Runge-Kutta iterative method to achieve 4 th and 5 th order accuracy. The selection of the appropriate solver is dependent on the type of ODE you are solving and the desired accuracy. MATLAB has many ODE solvers available for the coder. The state-space representation of this equation becomes: Where μ is the gravitational parameter of earth (398600 km 3/s 2)

#ODE45 MATLAB HOW TO#

For this tutorial, I will demonstrate how to use the ordinary differential equation solvers within MATLAB to numerically solve the equations of motion for a satellite orbiting Earth.įor two-body orbital mechanics, the equation of motion for an orbiting object relative to a much heavier central body is modeled as:












Ode45 matlab