-
Notifications
You must be signed in to change notification settings - Fork 10
/
trajectory.m
48 lines (45 loc) · 1.48 KB
/
trajectory.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
function [Ri,Vi] = trajectory(R0,V0,dt,step,mu)
%% Calculate And Plot Trajectory
%
% Jeremy Penn
% 22 September 2017
%
% Revision 22/09/17
%
% function [Ri] = trajectory(R0,V0,mu,dt,step)
%
% Purpose: This function calculates the trajectory of a satellite
% around the Earth over a given time interval.
%
% Inputs: o R0 - A 1x3 vector describing the initial position of the
% satellite.
% o V0 - A 1x3 vector describing the initial velocity of the
% satellite.
% o dt - The total time interval in seconds
% o step - The calculation step size in seconds
% o mu - The Standard Grav Parameter [OPTIONAL]. Defaults
% to Earth [km^3/s^2]
%
% Output: o Ri - A matrix of the calculated positions
% o Vi - A matrix of the calculated velocities
%
% Requires: universal_lagrange.m
%
clc; clear R V Long Lat t ind Ri;
if nargin == 4
mu = 398600; % [km^3/s^2] Standard Gravitational Parameter
end
t = 0; %[s] Initial time
ind = 1;
N = (dt / step);
Ri = zeros(N,3);
Vi = zeros(N,3);
while (t < dt)
[R, V] = universal_lagrange(R0, V0, t,mu);
Ri(ind,:) = R;
Vi(ind,:) = V;
ind = ind + 1;
t = t + step;
end
%
end