You are on page 1of 12

SCHOOL OF MATHEMATICAL SCIENCES

SEMESTER 2, ACADEMIC SESSION 2019/2020

MSS 381 A: MATHEMATICAL SOFTWARE LABORATORY

MINOR PROJECT

Lecturer’s Name : Dr. Syakila binti Ahmad

TITLE: BASKETBALL PROJECTORY

GROUP MEMBERS

Hasmaliyana binti Mohamaddiah (139051)

Muhamad Syahmi bin Mohd Isa (139058)


ALGORITHM

Projectile motion is a form of motion experienced by an object or particle and


moves along a curved path under the action of gravity only. Let the basketball
be launched with a force, f, initial angle in degree, θ, the time taken for the ball
be launched is assume, t shoot =0.5 s and the acceleration due to gravity,
g=9.81 m/ s ² . From the value of force, the velocity while shoot, v s h oot and the time
of the ball in the air can be determined.
The formula of force is

f =ma

m(v s h oot −v 0 )
f=
t shoot

f . v s h oot
v s h oot =v 0+
m

The horizontal and vertical components of the velocity vector are computed as
v x =v s h oot cos θ

v y =v s h oot sin θ−¿

The magnitude of the velocity can be obtain by

v=√ v x2 + v y 2

At any time, t the projectile’s horizontal and vertical displacement are


x=v s h oot t c os θ

1
y=v s h oot t sin θ− g t 2
2

The positive root will be determine as the time of flight of a projectile motion
which is the time from when the object is projected to the time it reaches the
surface given by
1 2
g t −v s h oot t sin θ+ y =0
2
The maximum horizontal range can be obtain by

x=v s h oot t cos θ

Maximum height is reached when v y =0. This can be calculate by

h=¿ ¿

The time taken for the basketball reach maximum height can be obtain by
v s h oot sin θ
t h=
g

The final velocity of the basketball when it reached at the ground

v final =v s h oot −g t ❑
PROGR AM LISTING

m.file for calculate the velocity, height and time

g=9.81; y0=2; x0=0;

balmass=3.0; tshoot=0.5;

force = input('Enter the force: ');

vshoot=tshoot.*(force./balmass);

th = input('Enter the angle in degrees of the ball: ');

rad = pi*th/180;

vy0 = vshoot*sin(rad); vx0 = vshoot*cos(rad);

tflight=roots([-g./2, vy0,y0]); tflight=max(tflight);

h_max=y0+((vy0^2)/(2.*g));

max_x=vx0*tflight;

th_max=vy0./g;

f_vel=vshoot-g.*tflight;

yhit=5;

thit=roots([-g./2, vy0,y0-yhit]); thit=max(thit);

force = input('Enter the force: ');

th = input('Enter the angle in degrees of the ball: ');

fprintf('The maximum height of the basketball (m): %f\n',h_max);

fprintf('Time flight (s): %f\n',tflight);

fprintf('The maximum horizontal range (m): %f\n',max_x);

fprintf('Time taken at maximum height (s): %f\n',th_max);

fprintf('Velocity of ball when reach ground (m/s): %f\n',f_vel);


m.file to plot
hold on

axis equal

t=linspace(0,thit,50);

axis([0 10 0 10])

x = x0 + vx0.*t; y = y0 + vy0.*t - 0.5 .* g .* t .^2;

hold on;

plot([8-.35,8+.35],[5,5],'r-','LineWidth',2)

plot([8+.30,8+.30],[0,6],'k','LineWidth',3)

for i=1:size(x,2)

if (i>1 && y(i)<=0)

break;

end

plot(x(i),y(i),'b.');

hold on;

ang=linspace(0,2.*pi,100);

br=0.2; %ball radius

xb=x(end)+br.*cos(ang); yb=y(end)+br.*sin(ang);

fill(xb,yb,'g')

pause (0.02);

end

hold on;

plot([8-.35,8+.35],[5,5],'r-','LineWidth',2) % plot the line for the rim

plot([8+.30,8+.30],[0,6],'k','LineWidth',3)
if (x(end)>7.65 && x(end)<8.4)

title("CONGRATULATIONS! YOU WIN!!!")

else

title("TRY AGAIN! T,T")

end
Command window

Enter the force: 72

Enter the angle in degrees of the ball: 65

The maximum height of the basketball (m): 8.028578

Time flight (s): 2.388014

The maximum horizontal range (m): 12.110621

Time taken at maximum height (s): 1.108633

Velocity of ball when reach ground (m/s): -11.426419


A SAMPLE RUN TO PROVE IT RUNS
CONCLUSION

Conclusion that can be made of using MATLAB for solving projectile motion
are :

1. We can investigate projectile motion by determining the force and initial


velocity given to the ball and ultimately predict the range of a projectile.
2. Projectile Motion equations were used to predict the accuracy of the ball
in this projectile motion.
3. We also can plot a 2D motion and observe the result to find the correct
initial value of force and angle.
REFERENCES

1. https://courses.lumenlearning.com/physics/chapter/3-4-projectile-motion/

2. https://www.toppr.com/guides/physics/motion-in-a-plane/projectile-motion/

3. https://au.mathworks.com/matlabcentral/answers/308853-how-do-i-create-a-
projectile-motion-function-with-the-input-of-angle-which-is-scalar-and-time-which

You might also like