| 12345678910111213141516171819202122232425262728293031 |
- clear; clc; close all
- %-------------------------------------------------
- % Pendulum's base position
- x0 = 0; y0 = 0;
- % Animation loop
- figure;
- for i = 1:length(t)
- % Update pendulum position
-
- % string
- hold on
- % ball
- hold off
- axis equal;
- xlim([-L, L]); % Set x-axis limits
- ylim([-L, 0.5]); % Set y-axis limits
- xlabel('x (m)');
- ylabel('y (m)');
- title(sprintf('Pendulum Animation (Angle = %.0f deg)', rad2deg(theta0)),'FontSize',14);
- pause(0.1);
- end
|