How does Matlab's RK4 solve an ODE?

1.1k Views Asked by At

As we know, when we integrate the ODE with the fourth-order Runge-Kutta method we call the differential equations (function), named fx(), 4 times. But when I run a Simulink model with ode4, Simulink executes model only 1 time, instead of 4. My simple model is shown here.

ODE4 Solver

The output of MatlabFunction increases by 1 after every execution. Fix-step is chosen and equal 0.1s. Integration time is 0.1s. Output of block MatlabFunction is 1, while in Matlab code, realizing the same model, i've got 4. So my question is, if Simulink really executes model only one time, instead of 4 times, on every step of ode4, in what meaning Simulink realizes the runge-kutta 4 method?

When using ode4, every time the function fx() is called, the inputs and ouputs may change their values (for example, when we integrate the equations of airplane motion, every time these equations are called we have got the different values of airplane state, of aerodynamic coefficients, of enviroment parameters, of engine state and ect). If Simulink executes model only 1 time per integration step, how it can ensure the numerical accuracy?

1

There are 1 best solutions below

5
On

Matlab has a number of basic solvers. There is no ode4 method. These are the methods listed.

enter image description here

If you're referring to ODE45. It is the Dormand-Prince method. It is a combination of the 4th and 5th order Runge-Kutta methods. How does it ensure accuracy? It is an adaptive algorithm. Since it knows the error approximation for fourth and fifth order it bounds them between them and makes local approximations. However, I am not sure how this works with Simulink exactly.

The method by which Runge-Kutta methods work is the same. It interpolates in space uses a Butcher Tableau. This is known as a predictor-corrector method. There is an infinite family of them. The higher the order you would seemingly get better accuracy but it takes more time. The tableau gives you the coefficients for the polynomials.