How to stop ode integration?

2 visualizaciones (últimos 30 días)
Artyom
Artyom el 6 de Feb. de 2014
Comentada: Walter Roberson el 6 de Feb. de 2014
I'm trying to solve a differential equations system with ode45 solver. But sometimes integration takes too much time because one of three values in the system becomes too small. As I understood I should use an event in ode function.
function [value,isterminal,direction] = events(t,y)
value = y(1) - 0.0000001;
isterminal = 1;
direction = 0;
How to write the event not just only for one y value, but for all three of them?

Respuesta aceptada

Walter Roberson
Walter Roberson el 6 de Feb. de 2014
function [value,isterminal,direction] = events(t,y)
miny = [0.0000001, 0.000000025, -83.9]; %for example
value = y < miny;
isterminal = 1;
direction = 0;
  2 comentarios
Artyom
Artyom el 6 de Feb. de 2014
Thank you.
Walter Roberson
Walter Roberson el 6 de Feb. de 2014
Ah, it should probably be
isterminal = ones(size(y));
direction = zeros(size(y));

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Ordinary Differential Equations en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by