# Second derivative of solution from ode45

5 views (last 30 days)
e_frog on 4 Nov 2020
Commented: e_frog on 5 Nov 2020
I have a system of 2 second order ODEs, which i converted to a system of fist order ODEs, which ode45 (or ode15s) needs as an input
my system input looks like this: as an output i get the vector , but I need the derivatives and . How can i get those?
I tried using the gradient function as suggested by Star Strider in this question: How to output derivative from ODE 45 but unfortunately that did not help.

Bjorn Gustavsson on 4 Nov 2020
Edited: Bjorn Gustavsson on 4 Nov 2020
After integrating your ODE-system you will have for some , and you have the function for your ODE-equations, f(t,X), one way to calculate the accelerations at times will be to simply call:
dxd2xdyd2ydt(i,:) = f(t_i,X(i,:));
Typically I use a regularly space array for the time in the call to ode45 and use the gradient-function, but the above should work - that is after all what we expect odeNN: to give us a solution X where that is true...
HTH
e_frog on 5 Nov 2020
ty it worked!

R2019b

### Community Treasure Hunt

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

Start Hunting!