Solving equations for a specified variable in terms of other variables

조회 수: 8 (최근 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 CenterFile Exchange에서 Calculus에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by