If a stationary ball is released at a height h0above the surface of the earth wi
ID: 1940324 • Letter: I
Question
If a stationary ball is released at a height h0above the surface of the earth with a vertical velocity ofv0 the position and velocity of the ball as a functionof time will be given by the equations
h(t) = 1/2 gt2 + v0t +h0
v(t) = gt + v0
where g is the accelration due to gravity(-9.81m/s2), h is the height above the surface of theearth (assuming no air friction) and v is the vertical component ofvelocity. Write a MATLAB program that prompts a user for theinitial height of the ball in meters and the velocity of the ballin meters per second and plots the height and velocity as afunction of time. Be sure to include proper labels in yourplot.
Explanation / Answer
The code is;
strResponse = input('input h0 ', 's');
h0=str2double(strResponse);
strResponse = input('input v0 ', 's');
v0=str2double(strResponse);
t=[0:0.1:10];
g=-9.81;
h=0.5*g*t.^2+v0*t+h0;
v=g*t+v0;
figureplot(t, h)title ('height as function of time')xlabel('time [sec]');ylabel('height [m]');
figureplot(t, v)title ('velocity as function of time')xlabel('time [sec]');ylabel('Velocity [m/sec]');
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.