How to Get Second Derivative in ode45 solver?

14 ビュー (過去 30 日間)
ercan duzgun
ercan duzgun 2022 年 7 月 21 日
コメント済み: ercan duzgun 2022 年 7 月 25 日
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

採用された回答

Sam Chak
Sam Chak 2022 年 7 月 21 日
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 件のコメント
ercan duzgun
ercan duzgun 2022 年 7 月 25 日
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

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeOrdinary Differential Equations についてさらに検索

タグ

製品


リリース

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by