How to 3D plot a bouncing ball

1 view (last 30 days)
James
James on 7 Oct 2014
Answered: 성빈 on 6 Oct 2022
Plot 5 bounces, x and y velocities are constant.
Here is what Ive got...
All of this was done long hand.. I know there is another way but i dont know how...
What the plot should look like...
So how do I do this?
  1 Comment
James
James on 7 Oct 2014
This is just code but not a picture.(to copy and paste) :)
alpha=25;
theta=30;
g = 9.81;
b=5;
v_0=20;
%v_x and v_y = constant
%v_x = v_0*sin(theta)cos(alpha)
%v_y = v_0*sin(theta)sin(theta)
v_x = 8.39;
v_y = 3.475;
%Initial bounce = v_0*cosQ = 20*cos30 = 17.82
%v_z depreciates by 80% after every bounce
v_z = [17.82 14.256 11.405 9.124 7.299];
%time between each bounce t_b = (2*v_z)/g
t = [3.633 2.91 2.33 1.86 1.488];
%Distances (to be plotted)
x = v_x*t;
y = v_y*t;
z=v_z*t - 0.5*g*t^2;

Sign in to comment.

Answers (2)

Chad Greene
Chad Greene on 7 Oct 2014
for n bounces, say 7:
v_z(1) = 17.82;
for n = 2:7
v_z(n) = .8*v_z(n-1);
end
t = 2*v_z/g;

성빈
성빈 on 6 Oct 2022
I think it's too late, however... here's the complete code.
close all;
clear all;
alpha=25;
theta=30;
g = 9.81;
b=5;
v_0=20;
%v_x and v_y = constant
v_x = v_0*sind(theta)*cosd(alpha);
v_y = v_0*sind(theta)*sind(theta);
%v_z depreciates by 80% after every bounce
v_z = [17.82 14.256 11.405 9.124 7.299 5.839];
%time between each bounce t_b = (2*v_z)/g
t = [0 3.633 6.543 8.873 10.733 12.221];
for num = 1:1:5
tt = t(num):0.001:t(num+1);
xx = v_x*tt;
yy=v_y*tt;
zz=v_z(num)*(tt - t(num)) - 0.5*g*(tt-t(num)).^2;
plot3(xx,yy,zz);
hold on;
end
hold off;
xlabel('x');ylabel('y');zlabel('z');title('bouncing ball');

Categories

Find more on 2-D and 3-D Plots in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!