How write an event function using a 6x1 state vector.
이전 댓글 표시
Hello, I am trying to write an event function where my state vector, Y, is a 6x1 vector made up of position and velocity
Y = [r; v] = [r1; r2; r3; v1; v2; v3]
r and v are 3x1 vectors as seen above.
I would like to have my ODE45 simulation stop when norm(r) <= (a certain scalar magnitude), but I am unsure how to do this with the event function.
답변 (1개)
Walter Roberson
2023년 4월 28일
function [value,isterminal,direction] = myEventsFcn(t,Y)
value = SCALAR - norm(Y(1:3));
isterminal = 1;
direction = 0;
end
This codes to stop when SCALAR - norm(Y(1:3)) is positive (actually, when it crosses 0). constant minus function is positive when function becomes less than the constant.
카테고리
도움말 센터 및 File Exchange에서 Programming에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!