# Representation in state-space of a system with ideal and real differentiating links in feedback

There are two systems in the state space with an ideal and a real differentiator.

For the first system, the code in Mathematica is as follows.

nsys = NonlinearStateSpaceModel[
x'[t] == D[Power[x[t], 2], t] + 0.01 Sin[10 t], x[t], u[t], x[t], t]
Plot[Evaluate@OutputResponse[{nsys, 1}, 0, {t, 0, 20}], {t, 0, 20}]


What will the code look like for receiving the output signal if instead of the ideal differentiator in feedback the real differentiator?

The equations can be constructed from the block diagram and then directly passed to NDSolve.

eqns = {x'[t] == u[t] + f[t], f'[t] + f[t] == D[Power[x[t], 2], t]} /. u[t] -> 0.01 Sin[10 t];
x[t] /. NDSolve[Join[%, {x[0] == 0.5, f[0] == 0}], {x[t], f[t]}, {t, 0, 5}];
p1 = Plot[%, {t, 0, 5}];


Or we can use SystemsConnectionsModel to build the model and go from there.

add = TransferFunctionModel[{{1, 1}}, s];
int = TransferFunctionModel[1/s, s];
sq = NonlinearStateSpaceModel[{{}, u^2}, {}, u];
diff = TransferFunctionModel[s/(s + 1), s];
{{1, 1} -> {2, 1}, {2, 1} -> {3, 1}, {3, 1} -> {4, 1}, {4, 1} -> {1, 2}},
{{1, 1}}, {{2, 1}}] // SystemsModelMerge
p2 = Plot[Evaluate@OutputResponse[{%, {0.5, 0.5^2}}, 0.01 Sin[10 t], {t, 0, 5}], {t, 0, 5}];


Both approaches should give the same result.

Show[p1, p2]


(The latter approach will not work for the ideal differentiator because NonlinearStateSpaceModel does not support descriptor systems yet.)

• Dear Suba Thomas, the question arose: is it possible to write down the equation of the above systems in the form $x'=Ax+Bu$ (with one state-space variable, not two), or because of the differentiating links is impossible? – dtn Jan 6 at 5:01
• @AndySol You can get an affine representation using AffineStateSpaceModel[eqns, {x[t], f[t]}, u[t], x[t], t]. It will have two states and will be of the form $x'=a(x)+b(x).u$ . The second state comes from the pole in the denominator of the real differentiator. (eqns = {x'[t] == u[t] + f[t], f'[t] + f[t] == D[Power[x[t], 2], t]}) – Suba Thomas Jan 6 at 15:06