ODE system with 2 degrees of freedom

19 visualizaciones (últimos 30 días)
Nader Mohamed
Nader Mohamed el 27 de Oct. de 2021
Comentada: Nader Mohamed el 28 de Oct. de 2021
I'm trying to write this system of odes and then solve it with ode45, but I'm having trouble writing the function for the system:
k,J1,J2 and b are known. I tried to write this code but it doesnt work:
function dydt = ODEsystem(t,y)
k = 100;
b = 10;
J1 = 0.2;
J2 = 0.1;
dydt = zeros(6,1);
dydt(1) = y(2);
dydt(2) = y(3);
dydt(3) = k/J1 * dydt(1) - k/J1 * dydt(4);
dydt(4) = y(5);
dydt(5) = y(6);
dydt(6) = b/J2 * dydt(5) + k/J2 * dydt(4) - k/J2 * dydt(1);
end

Respuesta aceptada

James Tursa
James Tursa el 27 de Oct. de 2021
Editada: James Tursa el 27 de Oct. de 2021
I only see two variables, θ1 and θ2, and each is part of a 2nd order equation. So that would mean a 2 x 2 = 4 element state vector, not 6 element state vector as you are using. E.g., I would have the states defined as
y(1) =
y(2) =
y(3) =
y(4) =
which would mean the derivative function would be:
function dydt = ODEsystem(t,y)
k = 100;
b = 10;
J1 = 0.2;
J2 = 0.1;
theta1ddot = k/J1 * y(1) - k/J1 * y(2);
theta2ddot = b/J2 * y(4) + k/J2 * y(2) - k/J2 * y(1);
dydt = [y(3);y(4);theta1ddot;theta2ddot];
end

Más respuestas (1)

David Goodmanson
David Goodmanson el 27 de Oct. de 2021
Editada: David Goodmanson el 28 de Oct. de 2021
Hi Nader,
you only need four variables, theta1, theta1dot, theta2, theta2dot (not six). Try
function dydt = ODEsystem(t,y)
k = 100;
b = 10;
J1 = 0.2;
J2 = 0.1;
% y = [theta1; theta1dot; theta2; theta2dot]
dydt = zeros(4,1);
dydt(1) = y(2);
dydt(3) = y(4);
dydt(2) = (k/J1)*(y(1)-y(3));
dydt(4) = (b/J2)*y(4) +(k/J2)*(y(3)-y(1));

Categorías

Más información sobre Programming en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2018b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by