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!