How to use ode45 in this case?

2 ビュー (過去 30 日間)
Elie Hatem
Elie Hatem 2021 年 5 月 28 日
編集済み: Elie Hatem 2021 年 5 月 28 日
Hello,
I have the variable ydd (y double dot) that I want to integrate twice to get the variable y.
The formula of ydd is:
ydd = -tan(phi).*(zdd + gravity)
where phi, zdd are vectors of size (1xn) containing different angles and accelerations at each time instant.
And, gravity is also a vector of size (1xn) containing a constant value (which is 9.81) repeated n times.
So, ydd is also a (1xn) vector containing different accelerations at each time instant.
How can I use ode45 to integrate ydd twice?
Thank you for taking the time to read my question.

採用された回答

Torsten
Torsten 2021 年 5 月 28 日
編集済み: Torsten 2021 年 5 月 28 日
ydot = y'(t0) + cumtrapz(t,-tan(phi).*(zdd+gravity));
y = y(t0) + cumtrapz(t,ydot),
plot(t,y)
where t is your (1xn) vector of times (t0,...,t_(n-1)) and y(t0) and y'(t0) are initial conditions (position and velocity at t=t0, respectively).
  3 件のコメント
Torsten
Torsten 2021 年 5 月 28 日
編集済み: Torsten 2021 年 5 月 28 日
t can be arbitrarily spaced, but must be increasing and of the same length as the other vectors, namely n.
You could use ODE45 for a solution, but since your equation only depends on t and not on y, it would be overkill to use this solver.
If you want to compare results, take a look at the example "ODE with time-dependent terms" in the ODE45 documentation. It can easily be adapted to solve your application.
Elie Hatem
Elie Hatem 2021 年 5 月 28 日
編集済み: Elie Hatem 2021 年 5 月 28 日
Alright I will check and compare both solutions. Thanks for your help!

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

その他の回答 (0 件)

カテゴリ

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

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by