How to delay a state derivative using ode solvers in MATLAB

2 visualizaciones (últimos 30 días)
patr chri
patr chri el 31 de Mayo de 2022
Comentada: Paul el 1 de Jun. de 2022
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 comentarios
patr chri
patr chri el 1 de Jun. de 2022
Thank you Steven for the recommendation, I have written another more realistic simple example illustrating my question.
Paul
Paul el 1 de Jun. de 2022
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?

Iniciar sesión para comentar.

Respuesta aceptada

patr chri
patr chri el 1 de Jun. de 2022
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):

Más respuestas (1)

Walter Roberson
Walter Roberson el 31 de Mayo de 2022
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 comentarios
Walter Roberson
Walter Roberson el 1 de Jun. de 2022
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 el 1 de Jun. de 2022
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.)

Iniciar sesión para comentar.

Categorías

Más información sobre Programming en Help Center y File Exchange.

Productos


Versión

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by