Problem 3 I1 Pointl A stone is dropped at zero velocity from
Problem 3: I1 Pointl A stone is dropped at zero velocity from the top of a building at time t 30. The differential equation that yields the displacement x from the top of the building is (with x 0 at t 0) d2x g -5V dt2 where g is the magnitude of gravitational acceleration, given as 9.8 m/s and Vis the downward velocity dt Calculate the displacement x and velocity v as functions of time with Runge Kutta method taking the time step as 0.5 second. Plot and V as a function of time t.
Solution
Function to calculate the solution :
function R=MyRK4(f,a,b,ya,M)
h=(b-a)/M;
Y=zeros(1,M+1);
T=a:h:b;
Y(1)=ya;
for j=1:M
k1=h*feval(f,T(j),Y(j));
k2=h*feval(f,T(j)+h/2,Y(j)+h*k1/2);
k3=h*feval(f,T(j)+h/2,Y(j)+h*k2/2);
k4=h*feval(f,T(j)+h,Y(j)+k3);
Y(j+1)=Y(j)+(k1+2*k2+2*k3+k4)/6;
end
R=[T\'*Y\'];
end
Now we have to define f and other variables so that we can call function.
Let a=0,M=10 (given),h=0.5 which gives b=5 Now ya=0
f=9.8-y
