Question: function [ total _ distance, num _ bounces _ required, distances ] = BallBounce ( h 1 , e ) % Compute total distance traveled

function [total_distance, num_bounces_required, distances]= BallBounce(h1, e)
% Compute total distance traveled
total_distance = h1*((1+ e^2)/(1- e^2));
% Initialize variables
distance = h1;
num_bounces =0;
distances =[];
% Iterate until the condition is met
while distance 0.95* total_distance
% Update distance traveled and number of bounces
distance = distance +2* e * distance;
num_bounces = num_bounces +1;
% 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
num_bounces_required = num_bounces;
end}
call code
h1=1;
e =0.7;
[TotalDist,BounceOut,z]= BallBounce(h1,e)
Check distance as a function of number of
bounces.
Variable z must be of size [18]. It is currently of size [13]. 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.
function [ total _ distance, num _ bounces _

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!