Using event function in matlab ode45 for multi-dimensional state vector
1 次查看(过去 30 天)
显示 更早的评论
Hello, I have a set of odes written in matrix form as Xdot = AX; I also have a desired value of the states X_des. X is a five dimensional vector. I want to stop the integration after all the states reach their desired values (or atleast close to them by 1e-3). How do I use event function in matlab to do this? (All the help I have seen are about 1 dimensional states)
PS: I know for sure that all the states approach their desired values after long time. I just want to stop the integration once they are 1e-3 within the desired values.
0 个评论
回答(1 个)
Steven Lord
2018-7-6
For the original question, consider the maximum difference between the current state and the desired steady state. When that maximum difference crosses your "close enough" threshold of 1e-3 in a downward direction, stop. Since the maximum difference is less than 1e-3, so are all the others.
For the new question asked by max gilles, the Events function can return a vector. See for example the orbitode example. In that case only one of the events is terminal, the other is simply logged and used to plot maximum distance after the ODE solver has completed its work.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Ordinary Differential Equations 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!