Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Please include script code and output (Use MATLAB, do NOT do by hand) Using MATL

ID: 3699063 • Letter: P

Question

Please include script code and output (Use MATLAB, do NOT do by hand)

Using MATLAB R2017b:

9. Vertical motion and energy. If an object is shot upward with an initial vertical velocity Vo, its height at any time t can be calculated by the equation: h(t) = ho + vot - where he is the initial height of the object, and g=9.8 m/s, 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 TE = PE + KE where m is the mass of the object, and vis 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 58 g tennis ball that is hit upward from an initial height of 0.8 m at a speed of 60 mph (R17.8 m/s), which computes for Nt=500 timesteps and Tfinal = 4s. 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, dhfdt, 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. Note: After the plot is complete, the legend can be dragged using the cursor to get a better view of the energy plot.

Explanation / Answer

%% Initial values

h0 = 0.8; %initial height

v0 = 17.8; %initial velocity

m = 58; %mass of the ball

g = 9.8; %gravity

%% function

syms t; %symbolic t

f_H(t) = h0 + v0*t - (g*(t^2)/2); %height function

f_V(t) = diff(f_H,t); %vertical velocity function , differentiate H with respect to t

%% Computing

i = 0; %index

for t=0:4/10:4

i = i + 1;

H(i) = double(f_H(t)); %height

V(i) = double(f_V(t)); %vertical velocity

%Above double is using to convert sym type to double type

  PE(i) = m*g*H(i);%Potential energy

KE(i) = (1/2)*m*((V(i))^2); %Kinetic energy

TE = PE(i) + KE(i); %total energy

end

%% Plots

subplot(311)

plot(t,H)

xlabel('time in sec')

ylabel('Height in meter')

titel('Height')

subplot(312)

plot(t,V)

xlabel('time in sec')

ylabel('Velcity in meter/sec')

titel('Vertical velocity')

subplot(313)

plot(t,KE,':r')

hold on %to plot next figures in same subplot

plot(t,PE,':g')

plot(t,YE,':b')

xlabel('time in sec')

ylabel('Energy in joule')

titel('Energy of the Ball')

legend('Kinetic energy',Potential Energy', 'Total Energy')

hold off

suptitle('Vertical Motion and Energy ')