Explain this MatLab code to a beginner programmer:

%%                                   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
% tMax = total time of the process
% epsilon = coefficient of restitution 
%
% PROCESS
% solve differential equation using Euler's method
% use crude approximation to determine when ball hits floor
%
% 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)
dt = 0.001;                              % time resolution --> seconds (s)
tMax = 20;                                    % maximum time range --> (s)
epsilon = 0.7;                     % coefficient of restitution (unitless)
%%                                                           set constants
ay = -9.8;                              % acceleratin due to gravity m/s^2
%%                        solve differential equation using Euler's method
%%                    Create interpolation data for velocity versus height
heights = [0, 2.5];               % heights at which velocity is known (m)
velocities = [0, vyo];         % velocities at corresponding heights (m/s)
vInterpolation = @(h) interp1(heights, velocities, h); % interpolation function

%%                        solve differential equation using Euler’s method
tArray = to;                                  % time range as an array (s)
y  = yo;                            % preallocate the y array (height) (m)
vy = vyo;                          % preallocate the vy array (height) (m)

% ------------------------------- calculate position as a function of time
while tArray(end) < (to+tMax)
% ----------------------------------------------------------- detect floor
    t = tArray(end);
    vyNext = vy(end) + ay*dt;
    yNext = y(end) + vy(end)*dt;
    
    if (yNext <= 0)            % => hit the floor with dt time resolution
        % Linear interpolation for velocity just before collision at y = 0
        vyCollision = vInterpolation(yNext);
        
        %                   Update the velocity and height after collision
        vyNext = - vyCollision*epsilon;
        yNext = 0;
        
        %     Append the interpolated velocities and heights to the arrays
        tArray = [tArray, t+dt/2, t+dt];
        vy = [vy, vyCollision, vyNext];
        y = [y, 0, 0];

% Sub-loop to handle smaller time intervals within the if-condition block
        dtwall = dt/1000;
        tn = tArray(end-1) + dt/2 + dtwall;
        remainingTime = dt - dtwall;
        while remainingTime > dtwall
            vyNext = vy(end) + ay*dtwall;
            yNext = 0; % Reset y position to zero since the ball changes direction
            
            % Append the velocities and heights to the arrays using the same dt determined by tArray()
            tArray = [tArray, tn];
            vy = [vy, vyNext];
            y = [y, yNext];
            
            tn = tn + dtwall;
            remainingTime = remainingTime - dtwall;
        end
    else
        % Append the next velocity and height to the arrays
        tArray = [tArray, t+dt];
        vy = [vy, vyNext];
        y = [y, yNext];
    end
end

%%                                                            plot results
figure(1);
clf;
plot(tArray,y,'b','lineWidth',1.8);
xlabel('time (seconds)');
ylabel('height (meters)');

figure(2);
plot(tArray,vy,'b','lineWidth',1.8);
xlabel('time (seconds)');
ylabel('velocity (meters)');