Baseball trajectory with drag and wind

4 ビュー (過去 30 日間)
david johnson
david johnson 2020 年 6 月 28 日
回答済み: John D'Errico 2020 年 6 月 29 日
I am working on modelling the trajectory of a baseball considering the drag from the velocity of the baseball, as well as a headwind. I have the following to setup my ode function:
function dudt = wind(~,u)
vx = u(3);
vy = u(4);
vmag = sqrt((vwind - vx)^2+vy^2);
dudt = [vx;vy;-dr*vmag*(vwind-vx);-g - dr*vmag*vy];
end
(dr, vwind, g are constants)
and to solve
[times,solnw] = ode45(@wind,[tstart,tstop],u0);
I get the following error:
Warning: Failure at t=1.959253e+00. Unable to meet integration tolerances without reducing the step size below the smallest value
allowed (3.552714e-15) at time t.
My equations seem to be correct wrt my model but I'm sure I am doing something wrong with vy for it to be breaking.
Thanks for the help.
  1 件のコメント
Image Analyst
Image Analyst 2020 年 6 月 28 日
I don't see a specific question, but perhaps this will help: debugging in MATLAB

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

回答 (1 件)

John D'Errico
John D'Errico 2020 年 6 月 29 日
This is almost a classical problem, and the reason stiff ODE solvers were provided. Essentially, when you get that error using ODE45, the problem is probably stiff. You can do some reading here:
The stiff ODE solvers in MATLAB are ode15s and ode23s. Hint: The last character in the name is s. :)
Call it the same way as you did ode45, just change the name.

カテゴリ

Help Center および File ExchangeProgramming についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by