%..................................................
%
%   ODE45 Function to Numerically Integrate the
%   Equation of Motion for a Ballistic Entry
%
%   LUNAR ATMOSPHERE
%
%..................................................

function ydot = eom(t,y)

%..Constants

Re   = 1737400;           %..Radius of Earth, m
g0   = 1.6;               %..Grav Acceleration, m/s^2
rho  = 0;                 %..Density, kg/m^3
B    = 471.8;             %..Ballistic Coefficient, kg/m^2
H    = 0;                 %..Scale Height, m

%..Equations

ydot = zeros(3,1);

v     = y(1);
gamma = y(2);
h     = y(3);

ydot(1) = (-rho*v^2)/(2*B) + (g0*((Re^2)/(Re+h)^2))*sin(gamma);

ydot(2) = (-v*cos(gamma))/(Re+h) + (((g0*((Re^2)/(Re+h)^2))*cos(gamma)))/v;

ydot(3) = -v*sin(gamma);