0
$\begingroup$

The FullForm of my equation final(obtained from System Modeler) is:

equations = FullForm@final

After copy the plain output, which output:

plainEqns=And[Equal[
  Times[2.`, QuantityVariable["fixed1.s0", "Length"], 
   QuantityVariable["spring1.c", "SpringConstant"]], 
  Plus[Times[-2.`, QuantityVariable["sine1.offset", "Unitless"]], 
   Times[QuantityVariable["mass1.L", "Length"], 
    QuantityVariable["spring1.c", "SpringConstant"]], 
   Times[2.`, QuantityVariable["spring1.c", "SpringConstant"], 
    QuantityVariable["spring1.s_rel0", "Length"]], 
   Times[-2.`, QuantityVariable["sine1.amplitude", "Unitless"], 
    Sin[Plus[QuantityVariable["sine1.phase", "Angle"], 
      Times[6.283185307179586`, 
       QuantityVariable["sine1.freqHz", "Frequency"], 
       Plus[t, Times[-1.`, 
         QuantityVariable["sine1.startTime", "Time"]]]]]]], 
   Times[2.`, QuantityVariable["spring1.c", "SpringConstant"], 
    QuantityVariable["mass1.s", "Length"][t]], 
   Times[2.`, QuantityVariable["mass1.m", "Mass"], 
    Derivative[1][QuantityVariable["mass1.v", "Speed"]][t]]]], 
 Equal[Times[QuantityVariable["spring2.c", "SpringConstant"], 
   QuantityVariable["damper1.s_rel", "Length"][t]], 
  Plus[Times[-1.`, QuantityVariable["sine2.offset", "Unitless"]], 
   Times[QuantityVariable["spring2.c", "SpringConstant"], 
    QuantityVariable["spring2.s_rel0", "Length"]], 
   Times[-1.`, QuantityVariable["sine2.amplitude", "Unitless"], 
    Sin[Plus[QuantityVariable["sine2.phase", "Angle"], 
      Times[6.283185307179586`, 
       QuantityVariable["sine2.freqHz", "Frequency"], 
       Plus[t, Times[-1.`, 
         QuantityVariable["sine2.startTime", "Time"]]]]]]], 
   Times[-1.`, 
    QuantityVariable["damper1.d", "TranslationalDampingConstant"], 
    QuantityVariable["damper1.v_rel", "Speed"][t]], 
   Times[-1.`, QuantityVariable["mass2.m", "Mass"], 
    Derivative[1][QuantityVariable["damper1.v_rel", "Speed"]][t]]]], 
 Equal[QuantityVariable["mass1.v", "Speed"][t], 
  Derivative[1][QuantityVariable["mass1.s", "Length"]][t]], 
 Equal[Derivative[1][QuantityVariable["damper1.s_rel", "Length"]][t], 
  QuantityVariable["damper1.v_rel", "Speed"][t]]]

How could I get all the expressions with a pattern QuantityVariable[var, SI]? Such as QuantityVariable["mass1.L", "Length"].

Note

I have finished it, using: Cases[List @@ planFinal, _QuantityVariable, -1]

Thanks for your attention, thank you, @bills Background

I wish I can solve the simplified differential equations with DSolve.

$\endgroup$

closed as off-topic by march, MarcoB, m_goldberg, José Antonio Díaz Navas, bbgodfrey Mar 24 at 22:16

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – march, MarcoB, m_goldberg, José Antonio Díaz Navas, bbgodfrey
If this question can be reworded to fit the rules in the help center, please edit the question.

  • $\begingroup$ Maybe you could find a simple example where the same problem occurs? $\endgroup$ – bill s Mar 23 at 4:13
  • $\begingroup$ @bills I have edited the original question. Thanks for attention. $\endgroup$ – PureLine Mar 23 at 4:16
0
$\begingroup$
expr = ToExpression@TagBox[...]

Cases[FullForm[expr], QuantityVariable[x : _, y : _] :> {x, y}, Infinity]
$\endgroup$
  • 2
    $\begingroup$ Why QuantityVariable[x : _, y : _] and not just QuantityVariable[x_, y_]? $\endgroup$ – J. M. is away Mar 23 at 4:21
  • $\begingroup$ @J.M.isslightlypensive Indeed. $\endgroup$ – Chris Degnen Mar 23 at 4:23

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