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
Problem Comments
2 Comments
Solution Comments
Show comments
Loading...
Problem Recent Solvers7
Suggested Problems
-
14125 Solvers
-
Find the longest sequence of 1's in a binary sequence.
6695 Solvers
-
How to find the position of an element in a vector without using the find function
2814 Solvers
-
345 Solvers
-
Who has power to do everything in this world?
486 Solvers
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
Nice problem. There should be much more problems involving solution of differential equations on Cody. :-)
I have tried many ways of getting isequal( round(...,2),y_correct) to evaluate to 'true' when round(...,2) is, in fact, equal to y_correct. But, they all fail on the Cody server. Why not just test whether abs(catapult(...) - y_correct) <= TOL.