2
$\begingroup$

The following are the state matrices A and B obtained by linearization using SystemModelLinearize ("DocumentationExamples. Modeling. Generator" is the circuit given by the official routine). I want to change this type of variable(Quantity variable) in the matrix to a variable that can be assigned(R1、R2、L), or to a variable that we define ourselves. What should I do?

If the case cannot run normally, you can open the website(https://reference.wolfram.com/language/ref/SystemModelLinearize.html.zh). The case is probably in the middle of the page.The bottom picture is the case shown.

spacemodel = 
     SystemModelLinearize["DocumentationExamples.Modeling.Generator", 
       Method -> {"SymbolicDerivative", 
           "SymbolicParameters" -> {"R1", "R2", "L"}}]
    R1 = 10;
    R2 = 20;
    L = 0.02;
    A = spacemodel[[1, 1]]
    B = spacemodel[[1, 2]]

enter image description here enter image description here

$\endgroup$
13
  • $\begingroup$ I get an error when I run your first line of code !Mathematica graphics SystemModelLinearize::bld: Failed to build model DocumentationExamples.Modeling.Generator. V 13.1 Where is this thing called "DocumentationExamples.Modeling.Generator" ?? $\endgroup$
    – Nasser
    Nov 24, 2022 at 5:53
  • $\begingroup$ reference.wolfram.com/language/ref/SystemModelLinearize.html.zh)You can open this URL. This routine is roughly in the middle of the page. $\endgroup$
    – chen chen
    Nov 24, 2022 at 6:15
  • $\begingroup$ It does not work. !Mathematica graphics SystemModelLinearize::bld: Failed to build model DocumentationExamples.Modeling.InvertedPendulum.Components.DCMotor. V 13.1 on windows. !Mathematica graphics SystemModelLinearize::bld: Failed to build model DocumentationExamples.Modeling.InvertedPendulum.Components.DCMotor. $\endgroup$
    – Nasser
    Nov 24, 2022 at 6:25
  • $\begingroup$ I guess it may be the version problem. I used Mathematica 13.0 $\endgroup$
    – chen chen
    Nov 24, 2022 at 6:27
  • $\begingroup$ it says ` [EXPERIMENTAL]` so I could have bugs. $\endgroup$
    – Nasser
    Nov 24, 2022 at 6:27

1 Answer 1

5
$\begingroup$

Too long for comment, but can you use these replacements for your symbolic variables? If not, then add a desirable output for A and B to your post.

R1 = Quantity[10, "Ohms"];
R2 = Quantity[20, "Ohms"];
L = Quantity[0.02, "Henries"];

rule1 = {QuantityVariable["R1", IndependentPhysicalQuantity[""]] -> 
   R1, QuantityVariable["R2", IndependentPhysicalQuantity[""]] -> R2, 
  QuantityVariable["L", IndependentPhysicalQuantity[""]] -> L}

A1 = spacemodel[[1, 1]] /. rule1 // UnitSimplify // FullSimplify

$$\left( \begin{array}{ccc} 0. & 1. & 0. \\ 0. & 0. & 0. \\ 0. & 50./\text{H} & -1500.\text{Hz} \\ \end{array} \right)$$

$\endgroup$
1
  • 1
    $\begingroup$ Thank you very much for your answer. I think your answer can meet my needs! $\endgroup$
    – chen chen
    Nov 24, 2022 at 10:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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