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 balls()
%% SYSTEM DEFINITION AND INITIAL CONDITIONS
% Set the parameters of the system being simulated. We use global
% variables on parameters that need to be plotted by this function and used
% by other functions for computing the motion.
% Positions are given in meters, and velocities are given in meters per
% second. The first element is the x-component, and the second is the
% y-component. This convention is used throughout the code.
tfinal = input(' Simulation ending time, in seconds (say 100): ');
tstepmaxode = input(' Maximum time step that ode45 is allowed to take, in seconds. (0.02) : ');
bluex = input(' Initial x coordinate blue ball : ');
bluey = input(' Initial y coordinate blue ball : ');
bluevx= input(' Initial x velocity coordinate blue ball : ');
bluevy= input(' Initial y velocity coordinate blue ball : ');
redx = input(' Initial x coordinate red ball : ');
redy = input(' Initial y coordinate red ball : ');
redvx= input(' Initial x velocity coordinate red ball : ');
redvy= input(' Initial y velocity coordinate red ball : ');
% Set the locations for the walls; these are global.
global leftWallX rightWallX lowerWallY upperWallY goalX goalY_low goalY_hi goal_amp
leftWallX = -2.0; % Horizontal position of the left wall of the table.
rightWallX = 2.0; % Horizontal position of the right wall of the table.
lowerWallY = -1.0; % Vertical position of the lower wall of the table.
upperWallY = 1.0; % Vertical position of the upper wall of the table.
goalX = 1.5;
% BOTH BALLS
ballDensity = 1000; % Ball density, in kilograms per meter cubed.
% blue BALL
% The blue ball is modeled as a circular particle with a fixed mass;
% radius is global.
blueBallWallE = 1.; % blue ball coefficient of restitution with the walls, unitless.
blueBallRadius = 0.10; % blue ball radius, in meters.
blueBallMass = ballDensity*0.01*pi*blueBallRadius^2; % blue ball mass, in kilograms.
blueBallInitialPosition = [bluex, bluey]; % Initial blue ball position, in meters.
blueBallInitialVelocity = [bluevx, bluevy]; % Initial blue ball velocity, in meters per second....