-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathinteg_RK4.m
executable file
·24 lines (22 loc) · 950 Bytes
/
integ_RK4.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% RK4 INTEGRATION FUNCTION
% Author: Saurav Agarwal
% Email: [email protected]
% Date: January 1, 2011
% Place: Dept. of Aerospace Engg., IIT Bombay, Mumbai, India
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function[Xnew,DX,Acceleration_body,AngV] = integ_RK4(dt,X,dth,de,da,dr);
[DX,Acceleration_body(1,:),AngV(1,:)] = eval_state_derivative(X,dth,de,da,dr);
XA = DX * dt;
XB = X + 0.5 * XA;
[DX,Acceleration_body(2,:),AngV(2,:)] = eval_state_derivative(XB,dth,de,da,dr);
Q = DX * dt;
XB = X + 0.5 * Q;
XA = XA + 2.0 * Q;
[DX,Acceleration_body(3,:),AngV(3,:)] = eval_state_derivative(XB,dth,de,da,dr);
Q = DX * dt;
XB = X + Q;
XA = XA + 2.0 * Q;
[DX,Acceleration_body(4,:),AngV(4,:)] = eval_state_derivative(XB,dth,de,da,dr);
Xnew = X + (XA + DX * dt)/6.0;
end