How to numerically integrate the planar equations of motion?

5 ビュー (過去 30 日間)
TKR
TKR 2022 年 6 月 20 日
コメント済み: TKR 2022 年 6 月 21 日
For example, i have this equation for deacceleration
Written in MATLAB as dV/dt = -(rho*V^2)/(2*B) - g0*sin(gamma)
B (constant), rho, and gamma are all defined variables.
I am trying to use ode45, but can not get this to be a valid funtion to even use ode45. Below is my input and error I am getting.
dVdt = @(t,V), -(rho*V^2)/(2*B) - g0*sin(gamma)
Error: Invalid expression. Check for missing or extra characters
Any suggetions on how to approch this problem correctly would be greatly apprciated.

回答 (2 件)

John D'Errico
John D'Errico 2022 年 6 月 20 日
編集済み: John D'Errico 2022 年 6 月 20 日
You need to learn how to write a function handle. What you wrote was incorrect syntax. Do you see the spare comma, AFTER the parens?
dVdt = @(t,V), -(rho*V^2)/(2*B) - g0*sin(gamma)
Instead, this next is valid MATLAB syntax:
dVdt = @(t,V) -(rho*V^2)/(2*B) - g0*sin(gamma);
I added a semi-colon at the end. Learn to do that, although it is not crucial. The semi-colon stops lots of crap being dumped to your command widow.
  1 件のコメント
TKR
TKR 2022 年 6 月 21 日
thank you! i was missing the ; just trying to get it to work.
big question now is to how to get it to work in ODE45

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


Torsten
Torsten 2022 年 6 月 20 日
編集済み: Torsten 2022 年 6 月 20 日
syms V(t) a1 a2
sol = dsolve(diff(V,t)==a1*V^2+a2)
sol = 
Now substitute a1 = -rho/(2*beta) and a2 = -g0*sin(gamma)

カテゴリ

Help Center および File ExchangeEarth and Planetary Science についてさらに検索

製品


リリース

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by