5
$\begingroup$

I started using Mathematica 12 and ran into difficulties. Namely, I want to compare the results of the calculation of a closed system from Simulink and in Mathematica. I rummaged around a bit on the Internet and found an implementation of nonlinear state spaces. Having written my code, I encountered a difficulty, namely the implementation of integration. Help me to understand. https://reference.wolfram.com/language/ref/NonlinearStateSpaceModel.html

enter image description here

enter image description here

nsys = NonlinearStateSpaceModel[{{u Subscript[x, 2], Subscript[x, 2] == Integral[Subscript[x, 1]]}, {Subscript[x, 2]}}, {Subscript[x, 1], Subscript[x, 2]}, u]
OutputResponse[nsys, Sin[t], {t, 0, 5}];
Plot[%, {t, 0, 5}]
$\endgroup$
3
$\begingroup$

You could do the following to get the NonlinearStateSpaceModel

nsys = NonlinearStateSpaceModel[x2'[t] == u[t] x2[t], x2[t], u[t], x2[t], t]

enter image description here

And then simulate it

Plot[Evaluate@OutputResponse[{nsys, 0.0001}, Sin[t], {t, 0, 20}], {t, 0, 20}]

enter image description here

Alternatively, you can use SystemsConnectionsModel and SystemsModelMerge to get nsys

product5 = NonlinearStateSpaceModel[{{}, u1  u2}, {}, {u1, u2}];
integrator4 = TransferFunctionModel[1/s, s];
SystemsModelMerge[SystemsConnectionsModel[{product5, integrator4}, 
       {{1, 1} -> {2, 1}, {2, 1} -> {1, 2}}, {{1, 1}}, {{2, 1}}]]

enter image description here

$\endgroup$
  • $\begingroup$ Dear Suba Thomas, thanks for your reply. The results are similar to what Simulink produces. Another question is whether it is possible to obtain a differential equation describing the output signal from a nonlinear state space. I mean the Nonlinear Article-Spas transformation -> Differential equation. And that means "gray dot" under the symbol x1. This notation is not known to me. $\endgroup$ – Andy Sol Aug 18 at 5:46
  • $\begingroup$ Not out of the box, but you can do something along the lines of With[{res = Normal[nsys]}, {Thread[D[res[[2]], res[[5]]] == res[[1, 1]]], res[[1, 2]]}]. The formal variables (\[FormalT], \[FormalX], etc) are kind of special variables. If you assign something to them it could mess up the results. $\endgroup$ – Suba Thomas Aug 19 at 13:36
  • $\begingroup$ I do not understand the meaning of this expression. Could you explain it in more detail? $\endgroup$ – Andy Sol Aug 20 at 6:39
  • $\begingroup$ Could you clarify what it is that you are not understanding? $\endgroup$ – Suba Thomas Aug 20 at 22:06
  • $\begingroup$ In principle, I feel that i can figure out the code by reading the directory on the Wolphram website. Only one thing I want to clarify - what does the "gray dot" mean under the symbol x1. $\endgroup$ – Andy Sol Aug 22 at 6:16

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.