How to Get Second Derivative in ode45 solver?

11 visualizzazioni (ultimi 30 giorni)
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

Risposta accettata

Sam Chak
Sam Chak il 21 Lug 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 Commento
ercan duzgun
ercan duzgun il 25 Lug 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

Accedi per commentare.

Più risposte (0)

Tag

Prodotti


Release

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by