Please show the whole code Im very confused Matlab code for

Please show the whole code... I\'m very confused. Matlab code for earth orbit

Using a software package such as MATLAB, create a plot of an Earth orbit with a = 31, 800 km and e = 0.6 for 0 lessthanorequalto theta lessthanorequalto 2 pi. The origin of the plot should be Earth. Perigee should be in the direction of the positive x axis (therta = 0). On this plot, you should label (by hand) the semimajor axis, semiminor axis, radius of perigee, radius of apogee, and the semiparameter (semilatus rectum) of the ellipse.

Solution

----------------------------------------------------------------------------------------------------------------------------------------------------------------------

Elliptic orbit:

%periapsis
rp = 500e3 + getradius(\'earth\');

%eccentricity
ec = .7;

%semimajor axis
a = getsemimajoraxis(rp,ec);

%apoapsis
ra = 2*a-rp;

%true anomaly
theta = [0:.1:360];

orbit = ellipse(theta,a,ec,\'earth\');

figure(1), plot(orbit.x,orbit.y); axis equal
Re = getradius(\'earth\');
x = Re*cosd(theta);
y = Re*sind(theta);
hold on
plot(x,y,\'color\',[0 1 1])
hold off

figure(2), plot(theta,orbit.V/1000)
xlabel(\'\\theta\'), ylabel(\'V (km/s)\')
%current time
c = clock;

%reset hour and second
c(4) = 12; %hour
c(5) = 0; %minute
c(6) = orbit.tau; %seconds

%ellapsed time
datetime(c)

%returns 14-Feb-2015 21:34:54, so it\'s about 9.5 hours later still on
%Monday
2

ans =
22-Feb-2015 21:34:54


-----------Elliptic orbit


%periapsis
rp = 500e3 + getradius(\'earth\');
%eccentricity
ec = .7;
%semimajor axis
a = getsemimajoraxis(rp,ec);
%apoapsis
ra = 2*a-rp;
%true anomaly
theta = [0:.1:360];
orbit = ellipse(theta,a,ec,\'earth\');
figure(1), plot(orbit.x,orbit.y); axis equal
Re = getradius(\'earth\');
x = Re*cosd(theta);
y = Re*sind(theta);
hold on
plot(x,y,\'color\',[0 1 1])
hold off
figure(2), plot(theta,orbit.V/1000)
xlabel(\'\\theta\'), ylabel(\'V (km/s)\')
%current time
c = clock;
%reset hour and second
c(4) = 12; %hour
c(5) = 0; %minute
c(6) = orbit.tau; %seconds
%ellapsed time
datetime(c)
%returns 14-Feb-2015 21:34:54, so it\'s about 9.5 hours later still on
%Monday
2
ans =
22-Feb-2015 21:34:54
3
The circular orbits at perigee and apogee are
7.6167 and 3.1997 km/s, respectively.


-----Parabolic orbit:


Sphere of influence is actually a chapter 5 concept, but is the distance at which the gravitational forces
between two objects is equal. Thus,
While an approximation, if we just estimate this as the point between the sun and the earth where
these forces balance, then if the orbital radius of Earth is , then
, and thus solution for r_E in gives
r_soi = getsphereofinfluence(\'earth\',\'sun\');
display([\'Radius from center of earth to sphere of influence is approximately \' num2str(r_soi)]);
%perifocal distance
rp = 500e3 + getradius(\'earth\');
%eccentricty
ec = 1; %always so for a a parabola
theta = -180:1:180;
orbit = parabola(theta,rp,\'earth\');
figure(3), plot(orbit.x,orbit.y); axis equal
Re = getradius(\'earth\');
x = Re*cosd(theta);
y = Re*sind(theta);
hold on
plot(x,y,\'color\',[0 1 1])
hold off plot(theta,orbit.V/1000)
xlabel(\'\\theta\'), ylabel(\'V (km/s)\')
Radius from center of earth to sphere of influence is approximately 924722538.0586
4
5
The time required to leave the sphere of influence is
D = calendarDuration(0,0,0,0,0,orbit.t(end))
% delta v required
deltav = [num2str((orbit.Vmax - orbit.Vcirc_rp)/1000) \' km/s\'];
D =
186h 28m 23.9429146040929s
The required to leave the sphere of influence is
display(deltav)
deltav =
3.155 km/s


---Hyperbolic orbit


%eccentricity
ec = 2.05;
%semimajor axis
a = -1.4e11;
%radial points of interest in orbit
r1 = getorbitradiusofcelestialbody(\'earth\');
r2 = getorbitradiusofcelestialbody(\'mars\');
%get orbit data
dr = (r2-r1)/100;
orbit = hyperbola([],a,ec,\'sun\',(r1:dr:r2));
, plot(orbit.x,orbit.y); axis equal
Rs = getradius(\'sun\');
x = Rs*cosd(0:1:360);
y = Rs*sind(0:1:360);
hold on
plot(x,y,\'color\',[.5 .5 .1])
Re = getorbitradiusofcelestialbody(\'earth\');
x = Re*cosd(0:1:360);
y = Re*sind(0:1:360);
plot(x,y,\'color\',[0 1 1])
6
Rm = getorbitradiusofcelestialbody(\'mars\');
x = Rm*cosd(0:1:360);
y = Rm*sind(0:1:360);
plot(x,y,\'color\',[1 .2 .2])
hold off
, plot(orbit.theta,orbit.V/1000)
xlabel(\'\\theta\'), ylabel(\'V (km/s)\')
7
The time required to go from Earth to Mars is
t = seconds2human(orbit.t(end)-orbit.t(1))
% delta v required
deltav = [num2str((orbit.V(1) - getcircularvelocity(5e5,\'earth\') - getcircularvelocity(1.4960e+11,\'sun\'))/1000) \' km/s\'];
t =
years: 0
months: 1
days: 10
hours: 0
minutes: 4
seconds: 1.611795342527330
The required to leave the sphere of influence is
display(deltav)
deltav =
14.841 km/s
8


------------------Set a Course for Makemake

bodies = [...
{\'Mercury\'};
{\'Venus\'};
{\'Earth\'};
{\'Mars\'};
{\'Ceres\'};
{\'Jupiter\'};
{\'Saturn\'};
{\'Uranus\'};
{\'Neptune\'};
{\'Pluto\'};
{\'Makemake\'};
];
color = [ ...
.9 .6 .1;
1 .5 0;
0 1 1;
1 .4 .1;
.8 .6 .3;
1 .5 .35;
1 .9 0;
0 .8 1;
.2 0 1;
.5 .5 .5;
.6 0 .6];

%plot the orbit
for ii = 1:length(bodies)
orbit = Kepler2cart(char(bodies(ii)));
ph(ii) = plot3(orbit.x,orbit.y,orbit.z,\'-\'); axis equal
set(ph(ii),\'color\',color(ii,:),\'linewidth\',1)
hold on
end
%now plot the position
for ii = 1:length(bodies)
orbit = Kepler2cart(char(bodies(ii)),juliandate(now));
ph(ii) = plot3(orbit.x,orbit.y,orbit.z,\'o\'); axis equal
set(ph(ii),\'color\',color(ii,:),\'markerfacecolor\',color(ii,:))
hold on
end
hold off
xlabel(\'x\')
ylabel(\'y\')
9
lh = legend(bodies,\'location\',\'northeastoutside\'); legend boxoff

Please show the whole code... I\'m very confused. Matlab code for earth orbit Using a software package such as MATLAB, create a plot of an Earth orbit with a =
Please show the whole code... I\'m very confused. Matlab code for earth orbit Using a software package such as MATLAB, create a plot of an Earth orbit with a =
Please show the whole code... I\'m very confused. Matlab code for earth orbit Using a software package such as MATLAB, create a plot of an Earth orbit with a =
Please show the whole code... I\'m very confused. Matlab code for earth orbit Using a software package such as MATLAB, create a plot of an Earth orbit with a =

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site