-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdemo_sun2.m
executable file
·65 lines (38 loc) · 1.23 KB
/
demo_sun2.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
56
57
58
59
60
61
62
63
64
65
% demo_sun2.m November 21, 2012
% this script demonstrates how to interact with the
% sun2 Matlab function which computes a precision
% ephemeris of the sun
% Orbital Mechanics with Matlab
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
global suncoef
% initialize sun ephemeris
suncoef = 1;
% begin simulation
home;
fprintf('\ndemo_sun2 - precision sun ephemeris\n');
date= datevec(datetime('now','TimeZone','UTC'));
month=date(2);
day=date(3);
year =date(1);
ethr=date(4);
etmin=date(5);
etsec=date(6);
day = day + ethr / 24 + etmin / 1440 + etsec / 86400;
jdet = julian(month, day, year);
[cdstr, utstr] = jd2str(jdet);
[rasc, decl, rsun] = sun2 (jdet);
fprintf('\ncalendar date ');
disp(cdstr);
fprintf('\nephemeris time ');
disp(utstr);
[h, m, s, rastr] = hrs2hms (24.0 * rasc / (2.0 * pi));
[d, m, s, decstr] = deg2dms (180.0 * decl / pi);
fprintf('\nright ascension ');
disp(rastr);
fprintf('\ndeclination ');
disp(decstr);
fprintf('\ngeocentric position vector and magnitude (kilometers)\n');
fprintf('\nrx %14.8f', rsun(1));
fprintf('\nry %14.8f', rsun(2));
fprintf('\nrz %14.8f', rsun(3));
fprintf('\n\nrmag %14.8f \n\n', norm(rsun));