The event that I set in ode15s doesn't happen. ADE problem.

1 view (last 30 days)
Hi,
I set an event in my ADE problem using ode15s to stop the integration when the event happens. The problem is that the independent variable only has a small step at the beginning, so when my variables are near the event they get suddenly a higher value so the event is not detected.
I´m integrating Xdot=x(1), Ydot=x(2), Zdot=x(3), where Xdot,Ydot,Zdot represents velocitys. I want my Algorithm to stop at a distance DIST from P, that represents a certain point. I´m sure my trajectory pass through P.
My event is the next one:
function [valor,fin,direccion]=efunxdotWP(t,x,P,DIST) valor=norm([P(1)-x(1),P(2)-x(2),P(3)-x(3)])-DIST; fin=1; direccion=0;
I observed that "valor" decreases but, when it is near 0, suddenly grows. Thus, the point get away from P because the event is not detected.
Do you know how to fix it?
Thank you very much.
Edit: I have tried to fix it using a DIST higher. In this way, I get negative values of "valor" when the event is near and I achieve convergence. Do you think there is another way?
Edit2: I found out what was happening.The behavior of my function is linear so, in order to save time, the ode15s got a big step since certain time. I used 'MaxStep' inside of odeset options in order to control the biggest feasible step. Thanks to 'MaxStep' I can stop the integration when the event has to happen.
I hope "Edit2" will be useful. Bye!

Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!