Rephrase this MatLab code:


%%                                   simulating a bouncing ball: my code
% This script simulates a ball dropped or thrown in a vertical direction
% under constant gravitational acceleration. The ball will hit the floor
% and it will bounce a multiple number of times based on the coefficient
% of restitution given by epsilon. We have just before/after a collision.
% epsilon = |just after velocity| divided by |just before velocity|
%
% INPUT
% yo = initial height of ball
% vyo = initial velocity of ball in the y-direction
% dt = time resolution
% nBounces = # of bounces the ball hits the floor (at the collision)
% epsilon = coefficient of restitution 
%
% PROCESS
% solve equation of motions exactly and numerically. take the points and
% store them in appropriate arrays for plotting the process.
%
% OUTPUT
% height versus time graph
% velocity versus time graph
clear all                                              % never not do this
%%                                                  set initial condition
to = 0;                                  % initial time on clock (seconds)
yo = 2.5;                                                     % meters (m)
vyo = 5;                                % velocity --> meters/second (m/s)

%%                                             set user-defined parameters
nBounces=25;
nPtsPerBounce=100;
epsilon=0.7;                       % coefficient of restitution (unitless)

%%                                                           set constants
ay=-9.8;                                % acceleratin due to gravity m/s^2

%%                                                       track each bounce
nptsPerBounce = 2*ceil(nPtsPerBounce/2);
npts = nBounces*nptsPerBounce;
nptsUp = round(nptsPerBounce/2);   % # of points to plot for ball going up
nptsDown = nptsUp;               % # of points to plot for ball going down
m = npts + 2*nptsPerBounce;          % extra "2*nptsPerBounce isn't needed
tArray = zeros(1,m);                            % a bit bigger than needed
yArray = zeros(1,m);
vyArray = zeros(1,m);

t0=to;
y0=yo;
vy0=vyo;
k=1;
tArray(k)=t0;
yArray(k)=y0;
vyArray(k)=vy0;
t=t0;


for b=1:nBounces
    %                                        find time to reach max height
    %          use formula "vyf = vyo + ay*dt" at top; vyf=0; dt = -vyo/ay
dtUp = -vy0/ay;              % time of flight to move up and reach the top
dt = dtUp/nptsUp;                 % breaks up time of flight into small dt
dtUp=0;                            % time to use in the kinematic equation

    for j=1:nptsUp                 % use to store some points for plotting
        k=k+1;                         % index for storing arrays — t,y,vy
        t=t+dt;                                             % process time
        dtUp=dtUp+dt;                          % time for kinetic equation
        vy = vy0 + ay*dtUp;                                % ball velocity
        y = y0 + vy0*dtUp + 0.5*ay*dtUp^2;                   % ball height
        %                                       store some frames for plot
        tArray(k)=t;
        yArray(k)=y;
        vyArray(k)=vy;

    end
    y0=y;


%                                               find time to hit the floor
%                        vy0=0 at the top; ball velocity changes direction
%           formula used: 2*ay*dy = vyf^2 - vyo^2  =>  vyf = sqrt(2*ay*dy)
%                                    dy will be -y, so vyf = sqrt(-2*ay*y)
%                 now use the formulas: cyf = vy0 + ay*dt  =>  dt = vyf/ay


vyf=-sqrt(-2*ay*y0);                    % ball velocity when it hits floor
dtDown=vyf/ay;             % => time it takes ball to go from top to floor
dt=dtDown/nptsDown;               % breaks up time of flight into small dt
dtDown=0;                          % time to use in the kinematic equation
    for j=1:nptsDown               % use to store some points for plotting
        k=k+1;                        % index for storing arrays, t, y, vy
        t=t+dt;                                          % time of process
        dtDown=dtDown+dt;             % time for balls' kinematic equation
        vy=ay*dtDown;                                    % ball's velocity
        y= y0 + 0.5*ay*dtDown^2;                             % ball height


        %                                       store some frames for plot
        tArray(k)=t;
        yArray(k)=y;
        vyArray(k)=vy;

    end
y0=0;                         % this value is 0, based on our calculations
vy0=vy;               % => ball's velocity going down as it hits the floor

%                              do bounce, apply coefficient of restitution
vy0=-vy0*epsilon;    % => just after the bounce, initial velocity going up
end

kMax=k;
tArray=tArray(1:kMax);
yArray=yArray(1:kMax);
vyArray=vyArray(1:kMax);