Question: Your Task Write a function called BallBounce that takes in values for the initial height of a ball above the ground ( h 1 )
Your Task
Write a function called BallBounce that takes in values for the initial height of a ball above the ground h and the coefficient of restitution between the ball and the ground e that does the following:
Finds the total distance traveled by the object in the limit that the number of bounces goes to infinity. This value should be the first output of your function.
Finds the number of bounces required for the ball to travel at least of the total distance it will travel. This value should be the second output of your function. Note that if the coefficient of restitution is very small, the ball will travel of the total distance after bounces ie during the initial fall to the ground
Define a row vector that stores the distance traveled as a function of the number of bounces. The last element of this row vector should be the distance traveled once the condition described above is met. This vector should should be the third output of your function. You can perform a preliminary check of this variable by making sure its first element corresponds to the distance traveled for bounces.
Function
function TotalDist BounceOut, z BallBounceh e
TotalDist h e e;
distance ;
BounceOut ;
Height h;
z h;
while distance TotalDist
if BounceOut
Height Height e;
distance distance Height;
z z distance;
else
distance h;
end
BounceOut BounceOut ;
end
BounceOut BounceOut ;
if zend TotalDist
zend;
end
end
Code to call your function
h;
e
TotalDistBounceOut,z BallBouncehe
Output
TotalDist
BounceOut
z
Previous Assessment: of Tests Passed
Check total distance calculation.
Check number of bounces calculation.
Check distance as a function of number of bounces.
Make sure your output here is a vector. Also make sure the last element of the vector is the distance traveled for the number of bounces that satisfies the minimum distance traveled condition.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
