function MxDot =  M3dxdt(Mt,missileState,targetState)
%% Missile is a 120 mm Rocket with an IR Seeker
% Compute Missile xDot = [velocity; acceleration]'
g = 9.8066; % acceleration due to gravity
gravity = [0; 0; -g]; % gravity vector
diameter = 0.120; % missile diameter in m.
S = XX; % reference area in m^2
[acousticSpeed,rho] = getRho(missileState);
Mspeed = norm(missileState(4:6));
mach = Mspeed/acousticSpeed;
timeCurve = [XX]';  %seconds
thrustCurve = [XX]'; % Newtons
massCurve = [XX]'; % kg

machCurve = [XX];
dragCurve = [XX];

machCurveB = [XX];
dragCurveB = [XX];

if(Mt<=timeCurve(end-1))
    Cd = interp1(machCurveB,dragCurveB,mach,'linear','extrap');
else
    Cd = interp1(machCurve,dragCurve,mach,'linear','extrap');
end
mass = interp1(timeCurve,massCurve,Mt,'linear','extrap');
thrust = interp1(timeCurve,thrustCurve,Mt,'linear','extrap');
%Compute acceleration --------------------------------------------
if Mspeed<=20
    step = 0;
else
    step = 1;
end
dragAccel = -0.5*rho*Cd*S*missileState(4:6)*norm(missileState(4:6))/mass;% drag acceleration in m/sec^2
thrustAccel = thrust*missileState(4:6)/(mass*(norm(missileState(4:6))));
guideAccel = getGuidance(Mt,missileState,targetState);
accel = dragAccel + thrustAccel + gravity*step + guideAccel; % total acceleration
MxDot = [missileState(4:6);accel];
end
