Best way to integrate equations of motion with zero order hold control inputs

6 次查看(过去 30 天)
I have some equations of motion that I want to integrate using an ODE solver. I also have a control input to these equations of motion that I want to implement as a zero-order hold input. The control input is a continuous function of states. The way I am currently doing this is by having my ODE solver (currently it is ode113) inside a for loop that iterates over the time intervals that I want the control input to be constant over. Other than specifying the initial step size for ode113, are there any other things I can do to make this integration more efficient? Or are there any alternative ways I should go about this? Any advice is greatly appreciated.

回答(1 个)

Sumukh
Sumukh 2024-9-23
编辑:Sumukh 2024-9-23
Hi Nick,
I assume that you are trying to solve a system of ODEs in MATLAB R2024b. I am assuming that the “zero-order hold control inputs” you are referring to are multiple initial conditions passed to the ODE in every iteration of the for-loop. Please go through the following points to improve the performance of your code:
  • There are two methods to solver a system of ODEs with multiple initial conditions. One method is to use a for-loop over the initial conditions, which I will assume is the method being used currently. Another faster method is to use vectorization to solve for every initial condition simultaneously. This improves the performance of the code significantly. You can refer to the following documentation about these two methods:
  • ODEs can be “stiff” that a “non-stiff” solver like “ode113” will be slow and inefficient in solving them. You can refer to the following documentation to understand stiffness in ODEs:
You can refer to the following example to know how to create an “ode” object for a system of ODEs and detect and solve stiff ODEs:
The “DetectStiffness” name-value argument in the “selectSolver” command can be used to select an appropriate solver for a system of ODEs defined in the “ode” object.
  • The “odeset” command creates an “options” structure that can be passed as an argument to the ODE solver. Apart from the “InitialStep” field, the “Jacobian” matrix can be provided for improving the performance, especially for stiff ODE solvers. You can refer to the following documentation about the various options available in addition to the “Jacobian”:
  • You can refer to the following example on equations of motion. The example solves a system of equations of motion for a baton thrown into the air:
I hope this answers your query.
  1 个评论
Nick
Nick 2024-9-25
The zero-order-hold implementation is on a control input and not on initial conditions. The problem has to be solved sequentially because the control input is dependent on the initial conditions, which themself are dependent on the previous control input and initial conditions and so on. I had no idea that ODE solutions can be vectorized though and that will be useful to me in other applications so thank you! I will also try out the stiffness detection with the problem based approach. I have not used this problem based approach yet but this seems to be the superior way now in the new versions of MATLAB

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Ordinary Differential Equations 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by