MATLAB: How to put a timer on the animation so that as the ball travels there would be a time indicator until it hits the ground

animationtimer

t=linspace(0,((10+5*sqrt(26))/11));
y=(-1.1*t.^2)+(2*t)+5;
x=linspace(0,0);
for k = 1:length(t)
plot(x(1:k),y(1:k),'o')
ylabel('Vertical distance \textit{y(t)} from a height of 5\textit{m} off the ground,in meters','interpreter','latex');
title('A plot of the trajectory \textit{y(t)}=$-1.1t^{2}+2t+5$,in meters,of a ball as a function of time \textit{t}, in seconds','interpreter','latex')
legend('\textbf{Ball}','interpreter','latex');
hold on
plot(x(1:k),y(1:k))
axis([-1 1 0 6])
if k ~= length(t)
pause(0.01);
clf
end
end

Best Answer

Use text() to place a string near the ball.
Adjust the number in pause() to control the speed of the ball.