If an object is shot upward with an initial vertical velocity v_0, its height at
ID: 3826109 • Letter: I
Question
If an object is shot upward with an initial vertical velocity v_0, its height at any time t can be calculated by the equation: h(t) = h_0 + v_0t - 1/2gt^2 where h_0 is the initial height of the object, and g = 9.8 m/s^2, the acceleration due to gravity. The object's potential energy PE (its energy due to its position above the ground), kinetic energy KE (the energy associated with its movement) and total mechanical energy TE (potential energy + kinetic energy) can also be calculated at each time t, using the following equations: PE = mgh KE = 1/2mv^2 TE = PE + KE where m is the mass of the object, and v is the vertical velocity of the object. The vertical velocity of the object is the derivative of the height with respect to time, dh/dt. Write a program, verticalMotion .m, for a 58g tennis ball that is hit upward from an initial height of 0.8 m at a speed of 60mph (almostequalto 17.8 m/s), which computes for Nt=500 timesteps and Tfinal = 4 s. a. The height, h, of the ball. b. The ball's vertical velocity, dh/dt. c. Its potential energy (PE), kinetic energy (KE) and total energy (TE). Using the subplot command (use doc subplot to get information on the subplot command) to plot and animate (with Nstride = 20) the following three graphs. a. The height, h, of the tennis ball. b. The vertical velocity, dh/dt, of the ball vs. time. c. The PE, KE, and TE of the ball vs. time. Use the legend command to create a legend that distinguishes the graphs from one another. Each plot should be titled and each axis should be labeled.Explanation / Answer
Source Code:
subplot(2,2,1)
t = linspace(0,4,500);
h = 0.8 + (17.8*t) + (9.8*0.5*(t^2)); % as per the given equation of height in the question.
plot(t,h)
xlabel('t')
ylabel('Height h(t)')
title('Subplot 1: height h');
subplot(2,2,2)
v = 17.8 - (9.8*t); % This equation I have derived by taking the derivative of the height equation with respect to t
plot(t,v)
xlabel('t')
ylabel('Velocity v(t)')
title('Subplot 2: velocity v');
subplot(2,2,3)
p = (0.058*9.8*0.8) + (0.058*9.8*17.8*t) - (0.5*0.058*9.8*9.8*(t^2)); % I have derived this equation by substituting the height equation h(t) in the potential energy equation (mgh)
plot(t,p,'DisplayName','PE')
xlabel('t')
ylabel('Potential Energy'); hold on;
k = 9.18836 - (10.11752*t) + (2.78516*(t^2)); % I have derived this equation by substituting the velocity equation v(t) (as derived by taking derivative) in the Kinetic energy equation (1/2mv^2)
plot(t,k,'--','DisplayName','KE')
xlabel('t')
ylabel('Kinetic Energy'); hold on;
l = (0.058*9.8*0.8) + 9.18836; % I have derived this equation by adding the two equations (PE + KE). The 't' terms and 't^2' terms get cancelled and we get a constant term as Total energy. As Total energy is always constant.
plot(t,l,'b--o','DisplayName','TE')
xlabel('t')
ylabel('Total Energy');
title('Subplot 3: PE, KE and TE');
%Sorry I am not able to provide you with output screenshots as I don't have MATLAB installed on my machine but I am pretty sure the code will work.