system of ordinary differential equations of the second order (Apollo's coordinates for the problem of three bodies)

4 views (last 30 days)
mi=(1/82.45);
mi_ast=1-mi;
f=@(t,z) [z(2);2*z(4)+z(1)-(mi_ast*(z(1)+mi)/(r1^(3)))-(mi*(z(1)-mi_ast)/(r2^(3)));z(4);-2*z(2)+z(3)-(mi_ast*z(3)/r1^(3))-(mi*z(3)/r2^(3))];
r1=@(t) sqrt((z(1)+mi)^(2)+z(3)^(2));
r2=@(t) sqrt((z(1)-mi_ast)^(2)+z(3)^(2));
[t,u]=ode45(f,[0 6.19216933],[1.2; 0;0;-1.0435750983031990726]);
plot(t,u)
options=odeset('RelTol',1e-5)
[t,u]=ode45(f,[0 6.19216933],[1.2; 0;0;-1.0435750983031990726],options);
SYSTEM OF DIFFERENTIAL EQUATIONS FOR APOLLO:
INITIAL CONDITIONS AND SOLUTIONS:
I have to use this transformation to create the system of ordinary differential equations:
I receive the following errors:

Answers (1)

Arturo Javier Aceves Ramírez
Hello fellas,
I made some modifications to the code, and its working!
clc; clear; close all;
mu= 1/82.45;
muq = 1-mu;
r1=@(z) sqrt(((z(1)+mu)^2)+(z(3)^2));
r2=@(z) sqrt(((z(1)-muq)^2)+(z(3)^2));
f=@(t,z) [z(2)
2*z(4)+z(1)-((muq*(z(1)+mu))/(r1(z)^3))-((mu*(z(1)-muq))/(r2(z)^3))
z(4)
-2*z(2)+z(3)-((muq*z(3))/(r1(z)^3))-((mu*z(3))/(r2(z)^3))];
[t,z]=ode45(f,[0 1*6.19216933],[1.2 0 0 -1.0435750983031990726]);
figure()
plot(t,z)
grid on
legend('x','xd','y','yd')
figure()
plot(z(:,1),z(:,3))
I changed the name of mi and mi_ast (not a really big change there).
The next thing that i changed was on the r1 and r2 variables. It needs to use the "z" as a parameter value that the ODE45 is using, instead of the "t". Also, as those are handle function, they need to have a parameter when called, thats why on the second and fourth formula I changed "r1" to "r1(z)", and so on.
Hopefully this help other people understanding the ODE45 function.
Best regards,
Arturo Aceves.
  1 Comment
Arturo Javier Aceves Ramírez
By the way, your specific issue was the way that you use "r1" and "r2" when you wrote f, because you didnt specified the variable that you want to send to the "r1" and "r2" handle functions.

Sign in to comment.

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!