Question: Please help, if for matlab... Code to call your function: h 1 = 1 ; e = 0 . 7 ; [ TotalDist , BounceOut,z

Please help, if for matlab...
Code to call your function:
h1=1;
e =0.7;
[TotalDist,BounceOut,z]= BallBounce(h1,e)
Thank you for code, still not working....
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
Please help, if for matlab... Code to call your

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!