Baseball trajectory with drag and wind

4 visualizzazioni (ultimi 30 giorni)
david johnson
david johnson il 28 Giu 2020
Risposto: John D'Errico il 29 Giu 2020
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.

Risposte (1)

John D'Errico
John D'Errico il 29 Giu 2020
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.

Categorie

Scopri di più su Programming in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by