Beruflich Dokumente
Kultur Dokumente
%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%CUSTOMIZABLE STATE VECTORS%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%SAMPLE VALUES:
%MOLNIYA ORBIT
%r= [0 -7000 -14000];
%v= [2 1 -0.5];
%vmag= 6175;
%runspeed= 300;
%GEOSTATIONARY ORBIT
% Constant parameters
mu = 398.6004418e12; % Planetary gravitational constant for Earth, (mu =
GMearth) (m^3/s^2)
earth_rad=6371000; % in m
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%
%CONVERTING STATE VECTORS INTO ORBITAL ELEMENTS%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%
V=v;
r=r*1000; %Position vector conversion to meters
%Eccentricity Vector
vtmp = v / mu;
ecc = cross(vtmp, hv);
ecc = ecc - rhat;
p = hhat(1) / (1 + hhat(3));
q = -hhat(2) / (1 + hhat(3));
const1 = 1 / (1 + p * p + q * q);
fhat(1) = const1 * (1 - p * p + q * q);
fhat(2) = const1 * 2 * p * q;
fhat(3) = -const1 * 2 * p;
ghat(1) = const1 * 2 * p * q;
ghat(2) = const1 * (1 + p * p - q * q);
ghat(3) = const1 * 2 * q;
h = dot(ecc, ghat);
xk = dot(ecc, fhat);
x1 = dot(r, fhat);
y1 = dot(r, ghat);
xlambdat = atan3(y1,x1);
M0=-M0;
end
E=M0;
for i=1:5
E = E + (M0 + e*sin(E) - E)/(1 - e*cos(E));
end
v= 2*atan(sqrt((1+e)/(1-e))*tan(E/2));
R = a*(1-e*cos(E));
Xeci = R*(cos(w + v)*cos(RAAN) - sin(w+v)*sin(RAAN)*cos(inc));
Yeci = R*(cos(w + v)*sin(RAAN) + sin(w+v)*cos(RAAN)*cos(inc));
Zeci = R*(sin(w + v)*sin(inc));
c=0;
while abs(r(1)-Xeci)>100 && abs(r(2)-Yeci)>100 && abs(r(3)-Zeci)>100 &&
c<15
if c~=0
if (c<3)
M0=2*pi-M0;
end
if (c<5 && c>=3)
M0=-M0;
end
if (c<10 && c>=5)
M0=M0+(pi/2);
if (c==9)
M0=iniM0;
end
end
if (c>=10 && c<15)
M0=M0-(pi/2);
if (c==15)
M0=iniM0;
end
end
end
E=M0;
for i=1:5
E = E + (M0 + e*sin(E) - E)/(1 - e*cos(E));
end
v= 2*atan(sqrt((1+e)/(1-e))*tan(E/2));
R = a*(1-e*cos(E));
b = a*sqrt(1-e^2);
Xeci = R*(cos(w + v)*cos(RAAN) - sin(w+v)*sin(RAAN)*cos(inc));
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%
%DRAWING THE STATIC VISUALIZATION COMPONENTS%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%
%DRAWING THE DYNAMIC VISUALIZATION COMPONENTS%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%
k=0;
long=1:rev_no*ceil(orbital_period/runspeed);
%Plotting the movement of the satellite
Xcoord(1)=r(1);
Ycoord(1)=r(2);
Zcoord(1)=r(3);
%Sun=light('Position',[1 0 0],'Style','infinite', 'Visible', 'on');
v= 2*atan(sqrt((1+e)/(1-e))*tan(E/2));
%Computing 'r' in polar coordinates
r = a*(1-e*cos(E));
GMST=GMST+(runspeed/86400)*2*pi;
%Computes the Cartesian Co-ordinates in ECI frame from 'r' and orbital
%elements
Xeci = r*(cos(w + v)*cos(RAAN) - sin(w+v)*sin(RAAN)*cos(inc));
Yeci = r*(cos(w + v)*sin(RAAN) + sin(w+v)*cos(RAAN)*cos(inc));
Zeci = r*(sin(w + v)*sin(inc));
rotate (earth, [0 0 1], (runspeed)*(360/86400))
rotate (Xaxis, [0 0 1], (runspeed)*(360/86400))
rotate (Yaxis, [0 0 1], (runspeed)*(360/86400))
if (GMST>2*pi)
GMST=GMST-2*pi
end
lat(k)=atan(Zeci/sqrt(Xeci*Xeci+Yeci*Yeci))*(180/pi);
%Pause
pause (0.01);
%Blast condition
if (sqrt (Xeci*Xeci+Yeci*Yeci+Zeci*Zeci) <= 6731000)
blast (Xeci, Yeci, Zeci, 2000000);
ErrorMsg='Blast Effected'
break;
end
M0=M0+sqrt(mu/(a*a*a))*runspeed; %Updating Mean Anomaly for next
iteration
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%DISPLAYING ALTITUDE RANGE AND ORBIT TYPE%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
perigee=a*(1-e);
apogee=a*(1+e);
altitude_low=(perigee-earth_rad)/1000
altitude_high=(apogee-earth_rad)/1000
if altitude_low>200 && altitude_high<2000
'Low Earth Orbit'
end
if altitude_low>2000 && altitude_high<35786
'Middle Earth Orbit'
end
figure (2);
set(gcf,'Menubar','none','Name','Earth Track', ...
'NumberTitle','off','Position',[10,350,1000,500], ...