Solving equations for a specified variable in terms of other variables

2 ビュー (過去 30 日間)
Alastair Poore
Alastair Poore 2019 年 1 月 29 日
コメント済み: Alastair Poore 2019 年 1 月 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])
Alastair Poore
Alastair Poore 2019 年 1 月 30 日
It's ok. Thanks for trying, ill try figure another way out

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeCalculus についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by