Bouncing Volleyball Simulation
Past Person- ard Secord Peson
Your tasks for this week are to (1) complete a
MATLAB simulation of a volleyball bouncing
across a flat viscoelastic surface and (2) plot
this system's energy over time. The system has
already been set up for you in MATLAB; the
starter code will create the graph shown at
right when you first runit. All you need to do is
fill in the function that computes the state
derivatives and then create the requested
graph at the bottom of the main code.
We recommend you follow these steps:
Change the names of the filenames to be simulate_volleyball_yourname.mand
compute_volleyball_derivatives_yourname. so that everyone will have unique file names.
Change the name of the function at the top of your compute volleyball derivatives file to match the
updated name of this file.
Set the value of the studentNames variable near the top of simulate_volleyball_yourname.m
Update the name of the derivative computation function being called by ode45 on line 108 of
simulate_volleyball_yourname.m so that it will call your personal function.
Run thesimulate_volleyball_yourname.mscript to make sure everything is working correctly. The ball
should move down and to the right, as shown above.
Program the derivative computation function step by step, based on Newton's second law. Use the
global variables BallMass (kg), g (m/s)), FloorPositionY (m), FloorStiffness (N/m), and FloorDamping
(Ns/m). Do not worry about the radius of the ball when determining whether it is touching the floor: just
test its center location against the y-position of the floor. The viscoelastic floor is a combination of the
linear elasticity from the puck's wall zone and the viscous friction from the puck's mud zone; it is a
spring and a damper in parallel. The floor does not apply any horizontal forces on the volleyball. Feel
free to change the values of the environment variables and the ball': initial conditions as you see fit.
At the bottom of the simulation code, calculate the system's kinetic energy, gravitational potential
energy, elastic potential energy, and their sum at each instant of the simulation. Then graph these
quantities over time in figure 2 with line styles and colors that can be distinguished from one another.
Examining this plot is a good way to test whether your simulation is working correctly. Make sure energy
is approximately conserved when the simulation includes only conservative forces.
Format your energy plot nicely, including axis labels and a legend, and make sure your code is clear and
If you're interested in studying this dynamic system a bit more, consider this opportunity for extra
credit. The simulation youjust completed models the impacts between the volleyball and the ground
using a one-sided spring and damper in parallel, so that the ball's states change smoothly.
The other way we have modeled impacts is using the coefficient of restitution.
When the simulation's floor damping is non-zero and positive, how well do the impact velocities agree
with the coefficient of restitution model? Make a plot that shows your analysis and include your
observations in comments in the code.
This material may consist of step-by-step explanations on how to solve a problem or examples of proper writing, including the use of citations, references, bibliographies, and formatting. This material is made available for the sole purpose of studying and learning - misuse is strictly forbidden.
function Xdot = compute_volleyball_derivatives_starter(~,X)
% This function computes the derivatives of the states for a bouncing volleyball.
% The input t is time in seconds.
% The input X is our state vector. It has four elements, arranged in a column. Thus it is a 4x1 vector, with four rows, and one column.
% The state vector's first element, X(1), is the horizontal position of the ball, in meters.
% The state vector's second element, X(2), is the vertical position of the ball, in meters.
% The state vector's third element, X(3), is the horizontal velocity of the ball, in meters per second.
% The state vector's fourth element, X(4), is the vertical velocity of the ball, in meters per second.
% Declare global variables.
global BallMass g;
global FloorPositionY FloorStiffness FloorDamping;
% Pull components from the input state vector X to make them easier to use below.
x = X(1);
y = X(2);
vx = X(3);
vy = X(4);
% Calculate the time derivatives of each state from the current states.
% For now make the ball move at constant velocity. You will update this!
xdot = vx;
if y > FloorPositionY
vxdot = 0;