1
$\begingroup$

I'm deriving dynamic equations for a simple system, this is what I get:

enter image description here

How can I rearrange these 2 equations into the form like this:

enter image description here

My code is:

Subscript[x, 1] = -Subscript[q, 1][t] R; 
Subscript[y, 1] = 0; 
Subscript[x, 2] = 
  Subscript[x, 1] + Subscript[l, c] Cos[Subscript[q, 2][t]]; 
Subscript[y, 2] = Subscript[l, c] Sin[Subscript[q, 2][t]];
Subscript[v, 1] = Sqrt[
  D[Subscript[x, 1], t]^2 + D[Subscript[y, 1], t]^2]; 
Subscript[v, 2] = Sqrt[
  D[Subscript[x, 2], t]^2 + D[Subscript[y, 2], t]^2];
Subscript[w, 1] = D[Subscript[q, 1][t], t];
Subscript[w, 2] = D[Subscript[q, 2][t], t];
K = 1/2 (Subscript[II, 1] Subscript[w, 1]^2) + 
   1/2 (Subscript[II, 2] Subscript[w, 2]^2) + 
   1/2 (Subscript[m, 1] Subscript[v, 1]^2) + 
   1/2 (Subscript[m, 2] Subscript[v, 2]^2); 
P = g*Subscript[l, c]*Subscript[m, 2]*Sin[Subscript[q, 2][t]]; 
L = K - P; 
eq1 = Simplify[
   D[D[L, Subscript[q, 1]'[t]], t] - D[L, Subscript[q, 1][t]] ==  
    u[t]];
eq2 = Simplify[
   D[D[L, Subscript[q, 2]'[t]], t] - D[L, Subscript[q, 2][t]] == 0];

Thank you!

$\endgroup$
2
  • $\begingroup$ please add your code to your question. to make it easy for people to try and help you $\endgroup$ Commented Feb 19, 2016 at 20:05
  • $\begingroup$ have you tried typing them into wolfram alpha? $\endgroup$ Commented Feb 19, 2016 at 20:15

1 Answer 1

4
$\begingroup$

this should get you started:

{{d1, m12}, {m11, zero}} =  CoefficientList[ eq1[[2]], {q1''[t], q2''[t]}]

note Simplify decided to put u[t] on the left and the eq1[[2]] is picking the right hand side of the simplified equation. You'd probably be better off to work directly with your left side expression before building it into an equation.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.