フィルターのクリア

how to stop dde23 when one of states reach certain value?

1 回表示 (過去 30 日間)
sourabh mittal
sourabh mittal 2018 年 9 月 18 日
コメント済み: sourabh mittal 2018 年 9 月 18 日
I want to stop dde23 when i am geeting 99% close to steady state and extract saturation time. I have written code of my system and then call dde23 to solve it. problem is am not able to terminate code when saturation is reached.

採用された回答

Torsten
Torsten 2018 年 9 月 18 日
Use the "Events" option of dde23.
Best wishes
Torsten.
  3 件のコメント
Torsten
Torsten 2018 年 9 月 18 日
function main
tstart = 0.0;
tend = 100.0;
options = ddeset('Events',@events);
sol = dde23(@ddex1,2,[0.7],[tstart tend],options);
tevent = sol.xe(1) % time of 99 % saturation
tint = linspace(tstart,tevent,20);
yint = deval(sol,tint);
plot(tint,yint)
end
function dydt = ddex1(t,y,Z)
ylag = Z(:,1);
dydt = y*ylag*(1-y);
end
function [value,isterminal,direction] = events(t,y,Z)
value(1) = y(1)-0.99;
isterminal(1) = 1;
direction(1) = 1;
end
sourabh mittal
sourabh mittal 2018 年 9 月 18 日
Thank you!

サインインしてコメントする。

その他の回答 (1 件)

Walter Roberson
Walter Roberson 2018 年 9 月 18 日
Perhaps relax RelTol ?
The normal way of stopping early is to use an event function that examines the current state and decides whether to terminate early.
However, I do not know how you would determine whether saturation has occurred. If it requires examining previous states, such as to determine that the change in values is small enough, then event functions cannot do that (but in that particular situation, changing tolerances can help.)

カテゴリ

Help Center および File ExchangeProgramming についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by