Documentos de Académico
Documentos de Profesional
Documentos de Cultura
% Condiciones iniciales
theta1_0 = pi/4; % Ángulo inicial del primer péndulo
theta2_0 = pi/2; % Ángulo inicial del segundo péndulo
theta1_dot_0 = 0; % Velocidad angular inicial del primer péndulo
theta2_dot_0 = 0; % Velocidad angular inicial del segundo péndulo
% Tiempo de simulación
t_start = 0; % Tiempo inicial
t_end = 5; % Tiempo final
dt = 0.1; % Paso de tiempo
% Condiciones iniciales
theta1(1) = theta1_0;
theta2(1) = theta2_0;
theta1_dot(1) = theta1_dot_0;
theta2_dot(1) = theta2_dot_0;
1
% Cálculo de las coordenadas x, y para cada péndulo
x1 = l1 * sin(theta1);
y1 = -l1 * cos(theta1);
x2 = x1 + l2 * sin(theta2);
y2 = y1 - l2 * cos(theta2);
2
function theta1_ddot = calculate_theta1_ddot(theta1, theta2, theta1_dot,
theta2_dot, l1, l2, m1, m2, g)
num1 = -g * (2 * m1 + m2) * sin(theta1) - m2 * g * sin(theta1 - 2 *
theta2) - 2 * sin(theta1 - theta2) * m2 * (theta2_dot^2 * l2 + theta1_dot^2 *
l1 * cos(theta1 - theta2));
den1 = l1 * (2 * m1 + m2 - m2 * cos(2 * theta1 - 2 * theta2));
theta1_ddot = num1 / den1;
end
3
4
Published with MATLAB® R2023a