I need help with my MATLAB code. I am trying to plot the semi major axis and eccentricity with the following code with rungge kutta method. I have two different nnn's in the code which produce two different step sizes. So, I am wondering why both give the same exact plots for semi-major axis and eccentricity. The orbital dynamics fucntion considers J2, drag, SRP, and third body effects.   % Orbital elements obtained from TLE inc = 63.5000118; % Inclination (degs) raan = 19.999977; % RAAN (degs) ecc = 0.001; % Eccentricity argp = 120.02165342; % argument of perigee (degs) v = 0; % True anomaly (degs)   a = 6584.697271; % Semi-major axis (km)   mu = 3.986e5; period = (2*pi*sqrt((a^3)/mu));     % Calculating the state vector in eci frame [x, y, z, vx, vy, vz] = kep2cart(a, ecc, inc, raan, argp, v); Y = [x, y, z, vx, vy, vz];   options = odeset('RelTol', 1e-12, 'AbsTol', 1e-12);   nnn1 = 800; t_step1 = period/nnn1; m6 = 50; h_step6 = t_step1/m6; t_total6 = 0:h_step6:10*period;   [t6, state_1] = ode45(@orbitalDynamics, t_total6, Y, options);     nnn2 = 1800; t_step2 = period/nnn2; m6 = 50; h_step7 = t_step2/m6; t_total6 = 0:h_step7:10*period;   [t7, state_2] = ode45(@orbitalDynamics, t_total6, Y, options); % t7 = t7(1:length(t6));       for i = 1:length(state_1) [a6(i), ecc6(i), inc6(i), raan6(i), argp6(i), f6(i)] = ... cart2kep(state_1(i,1), state_1(i,2), ... state_1(i,3), state_1(i,4), ... state_1(i,5), state_1(i,6));   end     for i = 1:length(state_2)     [a7(i), ecc7(i), inc7(i), raan7(i), argp7(i), f7(i)] = ... cart2kep(state_2(i,1), state_2(i,2), ... state_2(i,3), state_2(i,4), ... state_2(i,5), state_2(i,6));   end       figure(1) plot(t6, a6) xlabel('Time (s)') ylabel('a (km)') legend('nnn = 800')   figure(2) plot(t7, a7) xlabel('Time (s)') ylabel('a (km)') legend('nnn = 1800')     figure(3) plot(t6, ecc6) xlabel('Time (s)') ylabel('ecc')     figure(4) plot(t7, ecc7) xlabel('Time (s)') ylabel('ecc')

Elements Of Electromagnetics
7th Edition
ISBN:9780190698614
Author:Sadiku, Matthew N. O.
Publisher:Sadiku, Matthew N. O.
ChapterMA: Math Assessment
Section: Chapter Questions
Problem 1.1MA
icon
Related questions
Question

I need help with my MATLAB code. I am trying to plot the semi major axis and eccentricity with the following code with rungge kutta method. I have two different nnn's in the code which produce two different step sizes. So, I am wondering why both give the same exact plots for semi-major axis and eccentricity. The orbital dynamics fucntion considers J2, drag, SRP, and third body effects.

 

% Orbital elements obtained from TLE
inc = 63.5000118; % Inclination (degs)
raan = 19.999977; % RAAN (degs)
ecc = 0.001; % Eccentricity
argp = 120.02165342; % argument of perigee (degs)
v = 0; % True anomaly (degs)
 
a = 6584.697271; % Semi-major axis (km)
 
mu = 3.986e5;
period = (2*pi*sqrt((a^3)/mu));
 
 
% Calculating the state vector in eci frame
[x, y, z, vx, vy, vz] = kep2cart(a, ecc, inc, raan, argp, v);
Y = [x, y, z, vx, vy, vz];
 
options = odeset('RelTol', 1e-12, 'AbsTol', 1e-12);
 
nnn1 = 800;
t_step1 = period/nnn1;
m6 = 50;
h_step6 = t_step1/m6;
t_total6 = 0:h_step6:10*period;
 
[t6, state_1] = ode45(@orbitalDynamics, t_total6, Y, options);
 
 
nnn2 = 1800;
t_step2 = period/nnn2;
m6 = 50;
h_step7 = t_step2/m6;
t_total6 = 0:h_step7:10*period;
 
[t7, state_2] = ode45(@orbitalDynamics, t_total6, Y, options);
% t7 = t7(1:length(t6));
 
 
 
for i = 1:length(state_1)
[a6(i), ecc6(i), inc6(i), raan6(i), argp6(i), f6(i)] = ...
cart2kep(state_1(i,1), state_1(i,2), ...
state_1(i,3), state_1(i,4), ...
state_1(i,5), state_1(i,6));
 
end
 
 
for i = 1:length(state_2)
 
 
[a7(i), ecc7(i), inc7(i), raan7(i), argp7(i), f7(i)] = ...
cart2kep(state_2(i,1), state_2(i,2), ...
state_2(i,3), state_2(i,4), ...
state_2(i,5), state_2(i,6));
 
end
 
 
 
figure(1)
plot(t6, a6)
xlabel('Time (s)')
ylabel('a (km)')
legend('nnn = 800')
 
figure(2)
plot(t7, a7)
xlabel('Time (s)')
ylabel('a (km)')
legend('nnn = 1800')
 
 
figure(3)
plot(t6, ecc6)
xlabel('Time (s)')
ylabel('ecc')
 
 
figure(4)
plot(t7, ecc7)
xlabel('Time (s)')
ylabel('ecc')
 
 
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Elements Of Electromagnetics
Elements Of Electromagnetics
Mechanical Engineering
ISBN:
9780190698614
Author:
Sadiku, Matthew N. O.
Publisher:
Oxford University Press
Mechanics of Materials (10th Edition)
Mechanics of Materials (10th Edition)
Mechanical Engineering
ISBN:
9780134319650
Author:
Russell C. Hibbeler
Publisher:
PEARSON
Thermodynamics: An Engineering Approach
Thermodynamics: An Engineering Approach
Mechanical Engineering
ISBN:
9781259822674
Author:
Yunus A. Cengel Dr., Michael A. Boles
Publisher:
McGraw-Hill Education
Control Systems Engineering
Control Systems Engineering
Mechanical Engineering
ISBN:
9781118170519
Author:
Norman S. Nise
Publisher:
WILEY
Mechanics of Materials (MindTap Course List)
Mechanics of Materials (MindTap Course List)
Mechanical Engineering
ISBN:
9781337093347
Author:
Barry J. Goodno, James M. Gere
Publisher:
Cengage Learning
Engineering Mechanics: Statics
Engineering Mechanics: Statics
Mechanical Engineering
ISBN:
9781118807330
Author:
James L. Meriam, L. G. Kraige, J. N. Bolton
Publisher:
WILEY