Baseball Flight

Version 1.0.0 (2.39 MB) by Meg Noah
To calculate the trajectory of a ballistic baseball with air drag, wind pressure, and magnus force (lift or curve).
Updated 3 Jan 2020

View License

Equations of motion are solved with a Runge-Kutta method to find the path of a pitched or hit baseball through the air. The coefficient of drag is calculated for each step depending on the local ambient conditions of temperature and pressure; wind pressure is accounted for; and the ball may be given a spin around an arbitrary axis to emulate top, side, or back spin.

The examples illustrate how to model a fastball, curveball, slider, and slowball pitch, as well as how to model hit projectiles. The user inputs the initial position and velocity of the ball relative to the stadium. The user may initialize the environment (atmosphere and wind) via models or rawinsonde readily available on the internet. Examples are given for how to use the International Standard Atmosphere with climate zonal data, climate-based NRLMSIS (matlab implementation included) with climate zonal data, or acquire a sonde of real observational data for a particular event.

The sonde example simulates the recent record on August 9, 2018, at 7:46 PM EST in Yankee Stadium, Yankees rightfielder Giancarlo Stanton set a new home run record - the hardest-hit homer ever recorded by Statcast. The the ball's off-bat speed was 121.7 mph at a launch angle of 17.4 deg. Rangers starter Ariel Jurado pitched the ball at an measured 91.1 mph. Both the pitch and the hit are simulated.

The model is quite flexible: users can set the baseball size, weight, and coefficient of drag as a function of Reynolds number through colloquial inputs or numerically. The relative angle between the stadium and wind direction is easily updated to rotate through with a parameter sweep. Gravity, wind, and spin are easily turned on or off for trade-space investigations.

This model is useful for education settings, to understand magnitude of effects, for analysis of baseball flight path data, and as a test-bed for evaluating personal algorithms ore measured data useful for estimating lift, drag, and magnus forces.

Happy New Year!

Cite As

Meg Noah (2024). Baseball Flight (, MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2019b
Compatible with any release
Platform Compatibility
Windows macOS Linux
Find more on General Physics in Help Center and MATLAB Answers

Community Treasure Hunt

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

Start Hunting!
Version Published Release Notes