How I can understand which event the solver detected during the solution of an ODE?

1 次查看(过去 30 天)
Dear community,
I have three ODEs to solve, and each ODE is characterized by more than one stop condition. Consequently, I used event functions to detect when certain stop conditions occur during the solution of an ODE.
To clarify the thinking, I write to you three stop conditions of just one event function.
Consequently I wrote this function
function [value, isterminal, direction] = events3(sol3)
% Termination conditions:
% detect |zd| = 0
% detect theta = 0
% detect |theta| > pi/2
%
% zd = sol3(4)
% theta = sol3(1)
value = [abs(sol3(4)); sol3(1); +(abs(sol3(1)) > pi/2)];
isterminal = [1; 1; 1]; % stop the integration
direction = [0; 0; 0]; % all direction
end
Besides, I need to know which event the solver detected. For this reason, I call ODE solver with three additional output arguments, as
[t,y,te,ye,ie] = odeXY(odefun,tspan,y0,options)
The output ie suits my task. Nevertheless, I don't understand why sometimes it is a vector with one component or with two components. I thought that more than one condition was detected contemporary when it was a vector with two components. But it is not correct, since I saw that the ie vector sometimes has the same components, for instance ie = [1;1].
Could someone help me understand how this output works ?
Kind regards
Califfo

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Ordinary Differential Equations 的更多信息

产品


版本

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by