File size: 1,769 Bytes
5ab75a9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
56
57
58
59
60
61
function J = JacobianCartesian2EphoffsetFull(t,Xt,MeanXt,eph)
%
% Calculate the Jacobian, J = dE/dX, between the ephemeris-offset elements
% and the cartesian state
%
% Note: It is likely more efficient to calculate J = (dX/dE)^-1, using the
% function JacobianEphoffset2CartesianFull to calculate dX/dE. The reason
% for this is that the latter function needs to interpolate from the
% ephemeris table much less frequently
%
% INPUT:
% 
%   t  = Ephemeris time
%   Xt = Cartesian state at time t = (r',v')' [ km & km/s ]
%   MeanXt = mean Cartesian state at time t   [ km & km/s ]
%   eph = Ephemeris table structure
%
% OUTPUT:
%
%   J = dE/dX [6x6] = Jacobian matrix
%

% Persistent variable for warning
persistent warning_issued
if isempty(warning_issued)
    warning_string = ['Using JacobianCartesian2EphoffsetFull is ' ...
        'usually less efficient than using the inverse of ' ...
        'JacobianEphoffset2CartesianFull'];
    warning(warning_string);
    warning_issued = true;
end

% Initialize Jacobian Matrix
J = NaN(6,6);

% Perturbations km and km/s
epsX = [1e-4,1e-4,1e-4,1e-7,1e-7,1e-7];
twoepsX = 2*epsX;

% Numerically compute Jacobian Matrix using central differences method
for i = 1:6

    % Re-set/initialize perturbed states
    Xminus = Xt;
    Xplus  = Xt;

    % Perturb state
    Xminus(i) = Xt(i) - epsX(i);
    Xplus (i) = Xt(i) + epsX(i);

    % Convert the perturbed Cartesian states into Equinoctial states 
    Eminus = convert_cartesian_to_ephoffset(t,Xminus,MeanXt,eph);
    Eplus  = convert_cartesian_to_ephoffset(t,Xplus ,MeanXt,eph);

    % Partial derivatives based on central differences
    J(:,i) = (Eplus(1:6) - Eminus(1:6)) / twoepsX(i);

end
    
return
end