# Problem 46938. Numerical computation of the optimal shooting angle of a catapult

Consider a capapult that fires a projects into the air with an initial velocity. The free-flying projectile is subjected to air friction and a gravitional force. Given a desired target and an initial velocity , find the optimal shooting angle of the catapult that minimizes the distance between the target and the trajectory of the fired projectile.
tip 1: Consider the states and as the x- and y-position of the projectile, and and as the x- and y-velocity. Then, the trajectory of the projectile can be found by solving the following ordinary differential equation (ODE):
,
,
.
where , and is the friction coefficient between the air and the projectile. Use the ode45.m function to compute the trajectory of the projectile with initial conditions . Plotting vs. will result in the x-y trajectory of the projectile, as shown in the figure below.
tip 2: Use the following update law, to incrementally update the shooting angle :
where the smallest Euclidean distance between the trajectory of the projectile and the target , is a difference angle, and an update parameter.
Example of algorithm's numerical result:
theta = catapult(25,3,25)
theta =
0.8431

### Solution Stats

32.0% Correct | 68.0% Incorrect
Last Solution submitted on Mar 08, 2024