# How to code a Sum Block when working with Transfer Functions?

I am working using transfer functions models with Mathematica and i am missing a basic feature like the ability to use a Sum Block.

How could the model above be modeled?

Considering:

C = TransferFunctionModel[2];
P = TransferFunctionModel[1/(s + 2), s];

And noise being a generic signal like a sine wave or a constant noise.

• Are you trying to run simulations in the time domain or in the frequency domain? I note that your transfer function is defined in the s plane. Are you after a simulation or a symbolic analysis?
– Hugh
Jan 8, 2021 at 10:50
• I would like to run simulations in the time domain and do other tasks like transfer function shaping or stability studies in the Laplace Transform domain.
– zurg
Jan 8, 2021 at 11:16

There are many ways a sum block could be specified.

Directly:

sum = TransferFunctionModel[{{1, 1}}]

StateSpaceModel[{{}, {}, {}, {{1, 1}}}]

AffineStateSpaceModel[{{}, {}, {}, {{1, 1}}}, {}, {u1, u2}]

NonlinearStateSpaceModel[{{}, u1 + u2}, {}, {u1, u2}]

Or from the equation:

StateSpaceModel[{y[t] == u1[t] + u2[t]}, {y[t]}, {u1[t], u2[t]}, {y[t]}, t]

After that the complete system can be obtained using SystemsConnectionsModel and SystemsModelMerge:

c = TransferFunctionModel[2];
p = TransferFunctionModel[1/(s + 2), s];

SystemsConnectionsModel[{c, p, sum}, {{1, 1} -> {2, 1}, {2, 1} -> {3, 1}}, {{1, 1}, {3, 2}}, {{3, 1}}];
SystemsModelMerge[%]

• Thank you, i have to say that, while it is really simple, it's not easy to find on the docs. Now it is pretty clear.
– zurg
Jan 8, 2021 at 15:47