-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathStateTransAndX.m
56 lines (46 loc) · 1.23 KB
/
StateTransAndX.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
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
%{
...
Created on 24/2/2020 18:41
This file hands over the state transistion matrix (STM)
Inputs
------
1) G_var - Requisite Global data
2) X_guess - Guess vector (1 x 6) or (1 x 4)
3) fun - function to be integrated(Actually the variational equation)
4) tend - Stop time of integration
Outputs
--------
for all families
1) t - time steps of integrations(nsteps x 1), nsteps - decided by ODE
2) PHItf - Final STM at the end of trajectory
3) x - states - (nsteps x 42) or (nsteps x 20) vector after integration
4) xf - Final integrated vector (1 x 6) or (1 x 4) => final state after integration
Dependencies
------------
1) VarEq_Init(X_Guess)
2) Integrator(fun,x0,[0 tspan],options);
...
%}
function [t,PHItf,x,xf,PHI] = StateTransAndX(G_var,X_Guess,fun,tend)
VarEq_InitVal = VarEq_Init(X_Guess);
[tInteg,xInteg] = Integrator(G_var,fun,VarEq_InitVal,[0 tend]);
N = size(xInteg,2);
if N == 20
type = 'Planar';
else
type = 'ThreeDim';
end
switch type
case 'Planar'
t = tInteg;
PHI = xInteg;
PHItf = reshape(xInteg(end,1:16),4,4);
x = xInteg(:,17:20);
xf = xInteg(end,17:20);
case'ThreeDim'
t = tInteg;
PHI = xInteg;
PHItf = reshape(xInteg(end,1:36),6,6);
x = xInteg(:,37:42);
xf = xInteg(end,37:42);
end