How to stop ode integration?

조회 수: 1 (최근 30일)
Artyom
Artyom 2014년 2월 6일
댓글: Walter Roberson 2014년 2월 6일
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?

채택된 답변

Walter Roberson
Walter Roberson 2014년 2월 6일
function [value,isterminal,direction] = events(t,y)
miny = [0.0000001, 0.000000025, -83.9]; %for example
value = y < miny;
isterminal = 1;
direction = 0;
  댓글 수: 2
Artyom
Artyom 2014년 2월 6일
Thank you.
Walter Roberson
Walter Roberson 2014년 2월 6일
Ah, it should probably be
isterminal = ones(size(y));
direction = zeros(size(y));

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Ordinary Differential Equations에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by