How to Get Second Derivative in ode45 solver?

14 visualizaciones (últimos 30 días)
ercan duzgun
ercan duzgun el 21 de Jul. de 2022
Comentada: ercan duzgun el 25 de Jul. de 2022
Dear MATLAB users;
I would like to solve a nonlinear equation using ode45. ode45 solver provides time (t), position (x), velocity (x_dot) .
I need acceleration , second derivative (x_dotdot). However, I can't get x_dotdot as output from ode45. I looked at the options/parameteres of ode45. I couldn't find there information about that.
I know that I can get x_dotdot, using x_dot numerically by subtraction of xdot(step n) and xdot(n+1 step), by typing extra codes. But I just wondered if it is possible to do it without writing codes? Is it possible to get second derivative (x_dotdot) of ode45 by using options in ode45?
Thanks in advance.
Ercan

Respuesta aceptada

Sam Chak
Sam Chak el 21 de Jul. de 2022
You don't need to..., because you can see the elephant in the room (not sure if this is the correct metaphorical idiom; I'm not good at English idioms).
Say the system is given by .
f = @(t, x) [x(2); - 2*x(2) - x(1)];
[t, x] = ode45(f, [0 10], [1 0]);
xddot = - 2*x(:,2) - x(:,1); % the acceleration, second derivative (x_dotdot)
plot(t, xddot), grid on, xlabel('t')
  1 comentario
ercan duzgun
ercan duzgun el 25 de Jul. de 2022
Dear @Sam Chak thank you very much for your response. Really, you are right, it was really the elephant in the room :) . I am surprised how I didn't notice this very obvious thing. Thank you for showing me, explaining me in detailed.
Kind regards,
Ercan

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Ordinary Differential Equations en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by