Error with ode45 when solution approaches 0
Show older comments
Hi guys, I am trying to create an orbital model, but I get this warning when my orbiting particle approaches the zero position: 'Warning: Failure at t=2.334452e+02. Unable to meet integration tolerances without reducing the step size below the smallest value allowed (4.547474e-13) at time t'. I get the same error on the y coordinate and I'm not able to plot a nice elliptic orbit.
G = 6.7e-11;
Ito_mass=3.5e10;
Sat_mass=1.33;
P0=[60,20,0];
a=norm(P0);
v0=sqrt(G*Sat_mass*Ito_mass/a);
vy=v0/sqrt(1+P0(2)/P0(1));
vx=-vy*P0(2)/P0(1);
V0=[vx,vy,0];
t_per=[1:1:700];
initials=[P0(1),V0(1)];
options = odeset('RelTol',1e-4,'AbsTol',1e-6);
[tx,x]=ode45(@myode,t_per,initials,options);
figure
plot(tx,x)
initials=[P0(2),V0(2)];
[ty,y]=ode45(@myodey,t_per,initials,options);
figure
plot(ty,y)
and this is the function I pass to ode45
function myode=myode(t,y)
G = 6.7e-11;
Ito_mass=3.5e10;
Sat_mass=1.33;
myode(1)=y(2);
myode(2)=-G*Ito_mass*Sat_mass*y(1)/(norm(y(1)))^3;
myode=[myode(1),myode(2)]';
Accepted Answer
More Answers (0)
Categories
Find more on Numerical Integration and Differential Equations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!