Question: function [ total _ distance, num _ bounces _ required, distances ] = BallBounce ( h 1 , e ) % Compute total distance traveled
function totaldistance, numbouncesrequired, distances BallBounceh e
Compute total distance traveled
totaldistance h e e;
Initialize variables
distance h;
numbounces ;
distances ;
Iterate until the condition is met
while distance totaldistance
Update distance traveled and number of bounces
distance distance e distance;
numbounces numbounces ;
Store distance in the vector
distances distances distance;
end
Store the last distance in the vector
distances distances distance;
Output the total distance and number of bounces required
numbouncesrequired numbounces;
end
call code
h;
e ;
TotalDistBounceOut,z BallBouncehe
Check distance as a function of number of
bounces.
Variable z must be of size It is currently of size Check where the
variable is assigned a value.
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
