How to numerically integrate the planar equations of motion?

8 views (last 30 days)
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.

Answers (2)

John D'Errico
John D'Errico on 20 Jun 2022
Edited: John D'Errico on 20 Jun 2022
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 Comment
TKR
TKR on 21 Jun 2022
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

Sign in to comment.


Torsten
Torsten on 20 Jun 2022
Edited: Torsten on 20 Jun 2022
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)

Categories

Find more on Earth and Planetary Science in Help Center and File Exchange

Products


Release

R2021a

Community Treasure Hunt

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

Start Hunting!