| 123456789101112131415161718192021222324 |
- clear all;
- v_0 = 50;
- theta_0 = 45;
- h_0 = 0;
- g = 9.8;
- x = @(t) cosd(theta_0) .* v_0 .* t;
- y = @(t) h_0 + v_0 * sind(theta_0) .* t - (1/2) * g * t .^ 2;
- t = linspace(0, 10, 100); % Time vector from 0 to 10 seconds
- x_min = min(x(t)); y_min = min(y(t));
- x_max = max(x(t)); y_max = max(y(t));
- for t_current = t
- plot(x(1:t_current), y(1:t_current));
- hold on;
- plot(x(t_current), y(t_current), 'ro', 'MarkerSize',25);
- xlim([x_min x_max]);
- ylim([y_min y_max]);
- pause(0.05);
- hold off;
- end
|