MATLAB Answers

ODE event location but integration does not stop

5 views (last 30 days)
kyllen87 on 20 Apr 2020
I am trying to use the “Events” option of the odeset function to stop the solver integration of the ODE system at “steady state” (where vector dydt = 0), but the solver never stops (only when it reaches Inf [t = ~10^300]).
%% event function (saved as function file)
function [x,isterm,dir] = eventfun(t, y, parameters, rates)
dydt = cellmodel_odes(t, y, rates, parameters)
dy = norm(dydt, Inf)
x = dy
isterm = 1;
dir = 0;
%% script calling event function
% call solver routine
t0= 0;
xoverFcn = @(T, Y) eventfun(T, Y, parameters, rates);
opts = odeset('Events',xoverFcn);
[t,y]= ode15s(@(t,y) cellmodel_odes(t, y, rates, parameters), [t0 Inf], init, opts);

Answers (0)




Community Treasure Hunt

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

Start Hunting!