How can I implement runge kutta method to a control problem in Simulink ?
9 views (last 30 days)
Show older comments
Hello Everyone,
I have a question about the implementation of the Runge Kutta method in a control system. I have used a general inverted pendulum problem with a PID controller. What I want to achieve is trying to write my Runge Kutta code and compare it with Simulink ode4 solver. The point that I am stuck is the implementation of Runge Kutta with a control input. The general version of Runge Kutta shows only half and one time step ahead with state variables of ODE. However, in a control problem, you need to calculate the control input at
and
where h is time step. Somehow Simulink handles this problem and I couldn't find how Simulink calculates and approximates future control input values.








I have tried to calculate one step ahead control input
and interpolate the control input value
between
and
. The results are quite similar but they don't coincide with each other. I have shared the results below.






Could you please help me, how should we implement the control input to calculate in advance in the Runge-Kutta method? And Do you have knowledge about how Simulink calculates and implement control input when we select the ode4 solver selection?
4 Comments
Kristof
on 15 Nov 2022
I have the same problem, I am looking for a general soulution to this situation. I tried to do the following: I took the derivative of the input force (from the current and the previous value), and predicted the future by that. But it is tricky, that my PID evaulates a new input force by its own selfprediction?
Yuichiro Aoyama
on 16 Feb 2024
I am not sure if this is answering the question, but in the vido below, the same u(t) is used all over the integration interval and works well.
https://www.youtube.com/watch?v=OOL5Mo_jYGY
Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!