|
|
@@ -2,10 +2,11 @@ addpath("functions");
|
|
|
clear all; clc; close all;
|
|
|
|
|
|
G = 6.674e-11; m1 = 5.972e24; m2 = 1.989e30;
|
|
|
-initial_conditions = [1.496e11; 0; 0; 0; 0; 29780; 0; 0];
|
|
|
-t_span = [0 365.25*24*3600*3];
|
|
|
-f = @(t, Y) twoBodyODE(t, Y, G, m1, m2);
|
|
|
-[t, Y] = ode45(f, t_span, initial_conditions);
|
|
|
+initial_conditions = [1.496e11; 0; 0; 0; 0; 29780*1.2; 0; 0];
|
|
|
+t_span = [0 365.25*24*3600*10];
|
|
|
+f = @(t, Y) twoBodyODE(t, Y, G, m1, m2, 2, 1e21);
|
|
|
+options = odeset('RelTol', 1e-6, 'AbsTol', 1e-6);
|
|
|
+[t, Y] = ode45(f, t_span, initial_conditions, options);
|
|
|
|
|
|
x1 = Y(:, 1);
|
|
|
y1 = Y(:, 2);
|
|
|
@@ -13,10 +14,12 @@ x2 = Y(:, 3);
|
|
|
y2 = Y(:, 4);
|
|
|
|
|
|
figure;
|
|
|
-xlim([min([x1;x2]), max([x1;x2])]);
|
|
|
-ylim([min([y1;y2]), max([y1;y2])]);
|
|
|
+xlim([min([x1;x2;y1;y2]), max([x1;x2;y1;y2])]);
|
|
|
+ylim([min([x1;x2;y1;y2]), max([x1;x2;y1;y2])]);
|
|
|
|
|
|
-for i = 1:length(t)
|
|
|
+step = 3;
|
|
|
+
|
|
|
+for i = 1:step:length(t)
|
|
|
hold on;
|
|
|
|
|
|
plot(x1(1:i), y1(1:i), "Color", "b");
|
|
|
@@ -28,7 +31,7 @@ for i = 1:length(t)
|
|
|
pause(0.01);
|
|
|
hold off;
|
|
|
|
|
|
- if i < length(t)
|
|
|
+ if i <= length(t) - step
|
|
|
cla;
|
|
|
end;
|
|
|
end
|