Baseball trajectory with drag and wind

1 visualización (últimos 30 días)
david johnson
david johnson el 28 de Jun. de 2020
Respondida: John D'Errico el 29 de Jun. de 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.
  1 comentario
Image Analyst
Image Analyst el 28 de Jun. de 2020
I don't see a specific question, but perhaps this will help: debugging in MATLAB

Iniciar sesión para comentar.

Respuestas (1)

John D'Errico
John D'Errico el 29 de Jun. de 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.

Categorías

Más información sobre Programming en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by