Event functions with ode15s not halting integration
이전 댓글 표시
I want to halt integration when the global variable "phase" switches from 2 to 3 or from 3 to 2 (it is always either 2 or 3). Here (below) is how I set this up in my event function, but it does not work even when I output value2 and see that it crosses zero many times. Does the value that crosses zero have to be one that is solved for by the ode solver? i.e. does it have to be part of the y vector?
function [value,isterminal,direction] = stopSolver(y)
global phase
value1 = y(1);
if phase == 3
value2 = 1;
elseif phase == 2
value2= -1;
end
value = [value1; value2];
isterminal = [1; 1]; % Stop the integration
direction = [0; 0]; % detect all zeros (default)
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Ordinary Differential Equations에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!