필터 지우기
필터 지우기

How to delay a state derivative using ode solvers in MATLAB

조회 수: 2 (최근 30일)
patr chri
patr chri 2022년 5월 31일
댓글: Paul 2022년 6월 1일
Hello,
I would like to ask how it is possible to add a delay on the derivatives of the states that are being used inside a set of equations.
A simple random example to clarify what I mean:
function dz = example(t,z)
k = 2;l = 1;Is = 1;
x = z;
A = sin(x_dot)*l;
B = A*k;
x_dot = 1/Is*B;
dz = x_dot;
end
The above example in Simulink is quite simple to implement because we have the memory block to use for the x_dot. How could I implement the same in MATLAB? I thought of using a first order delay such as x_star_dot_dot = 1/tau*(-x_star_dot+x_dot), but I am not sure if this is the appropriate way to do it.
Many thanks
EDITED:
After Steven Lord's comment, here is a simple example of equations in which in order to find side slip angular velocity I need to know it beforehand.
  댓글 수: 5
patr chri
patr chri 2022년 6월 1일
Thank you Steven for the recommendation, I have written another more realistic simple example illustrating my question.
Paul
Paul 2022년 6월 1일
I'm curious about these equations. Usually, the equations of motions for an air vehicle do not exhibit an algebraic loop for the sideslip dynamics, at least to my undestanding. Would you mind providing a bit more insight into the source of these equations?

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

채택된 답변

patr chri
patr chri 2022년 6월 1일
For people with similar questions, one way to approach the solution to this loop is to use a dummy first-order-delay ode. For the specific example of the question, I did the following and I am able to get the same results as with Simulink (with a very small tau):

추가 답변 (1개)

Walter Roberson
Walter Roberson 2022년 5월 31일
I just noticed that you intend to use this with the ode solvers.
The answer is that using this with the ode solvers would violate the mathematics used for predictions, and you would get the wrong result or error.
Using persistent cannot help you for this purpose, as your function is evaluated 6 times with different times and boundary conditions for each successful step, and the "previous" call might be for different conditions with different hypothesized derivatives.
What you need to do is use dde23 or similar.
  댓글 수: 10
Walter Roberson
Walter Roberson 2022년 6월 1일
The memory/delay is to make the information into a state and use dde23 or equivalent.
If you have incoming information that you cannot characterize through its derivative then that would likely violate the conditions needed for Runge Kutta methods to work. dde23 has support for some cases of singularities that ode*() cannot handle.
Walter Roberson
Walter Roberson 2022년 6월 1일
To be explicit, there is no available memory/delay mechanism for the ode* routines, and such a mechanism would be incompatible with the way ode*() routines calculate.
RK methods essentially do a polynomial fit at carefully selected locations near the current boundary. Those carefully selected locations do not have a "history" to go back to. They are not points that are expected to be gone to in the future: they are chosen to provide information about the local slope. Sort of like sweeping a flashlight in a regular pattern as you walk in the dark, you do not expect to travel through most of the points you light up, but you use the information to figure out the best route. (And every once in a while there is a tree in the way and you do end up going through the bramble bush as the best of not-great choices.)

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

카테고리

Help CenterFile Exchange에서 Programming에 대해 자세히 알아보기

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by