Solve for Nonlinear State Space Equation
이전 댓글 표시
Trying to derive the Nonlinear steady state equation for a double pengelum. Solved for matrix [theta1;theta1dot;theta2;theta2dot]. Need in terms of [theta1dot;theta2doubledot;theta2dot;theta2doubledot]. Where theta1dot and theta2 dot would just be the variable but theta1doubledot and theta2doubledot would the values factored out of the respective equations.
solving for eqn 17 have matrix 18

output for equation 17 in terms of 20

clear; clc;
% Initalize variables
syms theta1(t) theta2(t) r1 r2 m1 m2 g u
% Initalize kinematic constraints
x1 = r1*sin(theta1);
y1 = -r1*cos(theta1);
x2 = x1+r2*sin(theta2+theta1);
y2 = y1-r2*cos(theta2+theta1);
% Initalize velocity equations
x1dot=diff(x1);
y1dot=diff(y1);
x2dot=diff(x2);
y2dot=diff(y2);
% Solve for potential energy
pe=m1*g*y1+m2*g*y2;
%Solve for kinetic energy
ke=1/2*m1*(x1dot^2+y1dot^2)+1/2*m2*(x2dot^2+y2dot^2);
simplify(ke);
% Solve for L=KE-PE
l=ke-pe;
simplify(l);
% Initalize variables
syms theta1dot theta2dot
% Solve for partial derivitive of L by theta1dot
eqn1=subs(diff(subs(l(t), diff(theta1(t)), theta1dot), theta1dot), theta1dot, diff(theta1(t)));
eqn1=simplify(eqn1);
% Solve for the time derivative of eqn1
eqn1=diff(eqn1);
eqn1=simplify(eqn1);
% Solve for partial derivitive of L by theta1
a=simplify(diff(l,theta1));
% Solve for first equation of motion
eqn1=simplify(eqn1-a)-u
% Solve for partial derivitive of L by theta2dot
eqn2=subs(diff(subs(l(t), diff(theta2(t)), theta2dot), theta2dot), theta2dot, diff(theta2(t)));
eqn2=simplify(eqn2);
% Solve for the time derivative of eqn2
eqn2=diff(eqn2);
eqn2=simplify(eqn2);
% Solve for partial derivitive of L by theta2
z=simplify(diff(l,theta2));
% Solve for second equation of motion
eqn2=simplify(eqn2-z)
[V,S] = odeToVectorField(subs(eqn1),subs(eqn2));
S=[S(3);S(4);S(1);S(2)]
V=[V(3);V(4);V(1);V(2)]
댓글 수: 6
Walter Roberson
2022년 12월 6일
What is your question?
Cason Cox
2022년 12월 6일
Walter Roberson
2022년 12월 6일
I do not see any theta1doubledot in your code?
Torsten
2022년 12월 6일
I think
d^2/dt^2 theta1(t)
d^2/dt^2 theta2(t)
are meant.
But it's already solved for them after applying "odeToVectorField", isn't it ?
Cason Cox
2022년 12월 6일
Torsten
2022년 12월 7일
You are mistaken. "odeToVectorField" solved for d/dt theta1(t) , d^2/dt^2 theta1(t), d/dt theta2(t) , d^2/dt^2 theta2(t).
If it could solve theta1(t) and theta2(t), you wouldn't have to integrate the equations using an ODE integrator (the call to which is missing in your code) - you already had the solution.
답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Numerical Integration and Differential Equations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


