| 12345678910111213141516171819 |
- function animate_ball(p)
- time = linspace(0, p.t_max, 100);
- [x_path, y_path] = projectile_motion(p, time);
- for cur_time = 1:length(time)
- hold on;
- xlim([p.x_min-1 p.x_max+1]);
- ylim([p.y_min p.y_max+1]);
- plot([0,0], [0, p.height_initial], 'LineWidth',2, 'Color','blue');
- plot(p.displacement, p.height_final, 'gs', 'MarkerSize',20);
- plot([p.displacement, p.x_max], [p.height_final, p.height_final], 'LineWidth', 2, 'Color', 'green', 'LineStyle', '-');
-
- plot(x_path(1:cur_time), y_path(1:cur_time), 'Color', "red");
-
- pause(0.05);
- hold off;
- end
- end
|