Use this MatLab code, but for the if-condition that identifies when the ball hits the wall or goes past the wall, modify the calculation by adding a linear interpolation. To do this, first assume the same equation of motion that would occur if the floor was not present. Then calculate the velocity that the ball will have just before the collision at 𝑦 = 0 using linear interpolation of a velocity versus height. Model the motion of the ball that is outside the time interval when it collides with the wall using a time resolution of 𝑑𝑡 = 0.001 seconds. At the wall, it will generally be the case that the time the ball hits the floor will not be a perfect multiple of 𝑑𝑡, but rather an incomplete time interval that must be ≤ 𝑑𝑡. As such, make tArray() non-uniform. Once the collision between the ball and floor takes place, you should then track the flight of the ball upward initially, and follow it back down until the ball hits the floor again. At this point, you will have the same situation. Repeat this cycle for 20 seconds. Each time you work out the time that the ball hits the floor, you will need to modify the tArray to reflect starting at the floor with some initial velocity upward.

%%                                simulating a bouncing ball: example 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
%%                                                           set constants
ay = -9.8;                              % acceleration due to gravity m/s^2
%%                        solve differential equation using Euler's method
tArray = to:dt:(to+tMax);                     % time range as an array (s)
npts = length(tArray);
y  = zeros(1,npts);                 % preallocate the y array (height) (m)
vy = zeros(1,npts);                % preallocate the vy array (height) (m)
y(1) = yo;
vy(1) = vyo;
% ------------------------------- calculate position as a function of time
  for i=1:npts-1
% ----------------------------------------------------------- detect floor
  t = tArray(i);
  vy(i+1) = vy(i) + ay*dt;
  y(i+1) = y(i) + vy(i)*dt;
    if( y(i+1) <= 0 )           % => hit the floor with dt time resolution
    vy(i+1) = - vy(i)*epsilon;
    y(i+1) = 0;
    end
  end
%%                                                            plot results
figure(1);
clf;
plot(tArray,y,'b','lineWidth',1.8);
xlabel('time (seconds)');
ylabel('height (meters)');
figure(2);
clf;
plot(tArray,vy,'b','lineWidth',1.8);
xlabel('time (seconds)');
ylabel('velocity (meters)');