matlabode45

Solving differential equations with discrete values in MATLAB using ode45


I have a differential equation-

L'(x) = F1(x,L(x))

Using ode45, I have obtained the solution for L(x). I have an array of values for L(x) denoted by L_val. Using this solution, I intend to solve another differential equation.

w'(x)=L(x)/x

How can I solve for w(x)? Especially since L(x) is not a function of x, but an array of discrete values.


Solution

  • Use the cumulative trapezoidal integration function: https://fr.mathworks.com/help/matlab/ref/cumtrapz.html

    Alternatively, you may use other rules with a better accuracy (Simpson's rule, search in Matlab central for the function file). Another pragrmatic way is too compute a high-order interpolant of your function and to integrate it directly.