I'm trying to stop an ode45 solver when the altitude gets below a certain value, but it isn't working.
The code is below - I want to stop it when r gets to 10 km. I don't want to use an rdot value (vardot(1)=rdot).
tRange=[0,350];
var=[r;lat;long;u;v;w;e0;e1;e2;e3;omegaX;omegaY;omegaZ]
opts=odeset('Events',@EndEvents,'InitialStep',1e-6,'RelTol',1e-5);
[t,vardot]=ode45(@Trajectory,tRange,var,opts)
function [value,isterminal,direction]=EndEvents(t,vardot)
value = (var(1)-10000);
isterminal=1;
direction=0;
end

 Réponse acceptée

Torsten
Torsten le 10 Mar 2017
function [value,isterminal,direction]=EndEvents(t,var)
instead of
function [value,isterminal,direction]=EndEvents(t,vardot)
Best wishes
Torsten.

Plus de réponses (0)

Catégories

En savoir plus sur Programming dans Centre d'aide et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by