Solving equations for a specified variable in terms of other variables

7 次查看(过去 30 天)
I am trying to solve euqation (13) and (16) as listed on this website https://www.myphysicslab.com/pendulum/double-pendulum-en.html
This is what I have attempted so far however I am running into errors
syms g x1 y1 x2 y2 l1 l2 m1 m2 theta1 theta2 omega1 omega2 alpha1 alpha2 dy1 dy2 dx1 dx2 d2y1d d2y2 d2x1 d2x2
x1= l1*sin(theta1);
y1= -l1*cos(theta1);
x2 = x1+l2*sin(theta2);
y2 = y1-l2*cos(theta2);
dx1 = omega1*l1*cos(theta1);
dy1 = omega1*l1*sin(theta1);
dx2 = dx1 + omega2*l2*cos(theta2);
dy2 = dy1 + omega2*l2*sin(theta2);
d2x1 = -omega1^2*l1*sin(theta1)+alpha1*l1*cos(theta1);
d2y1 = omega1^2*l1*cos(theta1)+alpha1*l1*sin(theta1);
d2x2 = d2x1-omega2^2*l2*sin(theta2)+alpha2*l2*cos(theta2);
d2y2 = d2y1+omega2^2*l2*cos(theta2)+alpha2*l2*sin(theta2);
solve('sin(theta1)*(m1*d2y1+m2*d2y2+m2*g+m1*g)==-cos(theta1)*(m1*d2x1+m2*d2x2)', 'alpha1')
solve('sin(theta2)*(m2*d2y2+m2*g)==-cos(theta2)*m2*d2x2', 'alpha2')
Any help is much appreciated

回答(1 个)

Eugenio Grabovic
Eugenio Grabovic 2019-1-30
编辑:Eugenio Grabovic 2019-1-30
syms g l1 l2 m1 m2 theta1 theta2 omega1 omega2 alpha1 alpha2
x1= l1*sin(theta1);
y1= -l1*cos(theta1);
x2 = x1+l2*sin(theta2);
y2 = y1-l2*cos(theta2);
dx1 = omega1*l1*cos(theta1);
dy1 = omega1*l1*sin(theta1);
dx2 = dx1 + omega2*l2*cos(theta2);
dy2 = dy1 + omega2*l2*sin(theta2);
d2x1 = -omega1^2*l1*sin(theta1)+alpha1*l1*cos(theta1);
d2y1 = omega1^2*l1*cos(theta1)+alpha1*l1*sin(theta1);
d2x2 = d2x1-omega2^2*l2*sin(theta2)+alpha2*l2*cos(theta2);
d2y2 = d2y1+omega2^2*l2*cos(theta2)+alpha2*l2*sin(theta2);
eq1 = sin(theta1)*(m1*d2y1+m2*d2y2+m2*g+m1*g)==-cos(theta1)*(m1*d2x1+m2*d2x2);
eq2 = sin(theta2)*(m2*d2y2+m2*g)==-cos(theta2)*m2*d2x2;
solutions = solve([eq1 eq2],[alpha1 alpha2])
If u check solver helper its written that it doesn't accept char vectors anymore and requires just symbolycs. Should be working now. In addition a system of equations requires to be solved within the same solver.
  9 个评论
madhan ravi
madhan ravi 2019-1-30
+1 Eugenio , appreciate your effort,
you can also change your last line to:
[alpha1 alpha2] = solve([eq1 eq2],[alpha1 alpha2])

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Calculus 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by