# Operations on transfer function model

Suppose I have a transfer function defined via TransferFunctionModel, e.g. tf == TransferFunctionModel[{{1/s}}, s]. How can I perform operations on tf, e.g. multiplication. As an example, I may want to use it as follows RootLocusPlot[k tf, {k, 0, 10}] which does not work.

Is there a way to extract a transfer function model such that it can be modified, e.g. similar to the way Normal works for StateSpaceModel?

You Just use the tf, with no k multiplied in the call to RootLocusPlot.

The k goes to the tf it self. Like this

sys = TransferFunctionModel[k*(s^2 + 2 s + 4)/(s (s + 4)(s + 6)(s^2 + 1.4 s + 1)), s];
RootLocusPlot[sys, {k, 0, 100},
ImageSize -> 300,
GridLines -> Automatic,
GridLinesStyle -> Dashed, Frame -> True, AspectRatio -> 1]


Is there a way to extract a transfer function model such that it can be modified, e.g. similar to the way Normal works for StateSpaceModel

I am not sure what you mean. the tf, is the polynomial ratio in s you had at the start, so you have this allready. You can always go First@tf to get it again.

• Is it always the case that tf == TransferFunctionModel[tf[[1, 1]]/tf[[1, 2]], s]? – Mathabc Jan 11 '15 at 22:26
• Yes. transfer function, before passing it to Mathematica's TransferFunctionModel, is just ratio of 2 polynomials, like in the textbooks. So this is tf= k * N(s)/D(s), where N(s) is the numerator poly, and D(s) is the denominator poly. Now, you just do fancyTf=TransferFunctionModel[tf] only to be able to use fancyTf as a Mathematica transfer model. Since mathematica only knows it inside this wrapper. (ps. you should use == in the above, it is just =, a normal assignment) – Nasser Jan 11 '15 at 22:30

You can do this with the mathematica model connections. For the full list see http://reference.wolfram.com/language/guide/ModelConnections.html

For example using the function SystemsModelSeriesConnect:

tf = TransferFunctionModel[{{1/s}}, s];

SystemsModelSeriesConnect[TransferFunctionModel[k, s], tf]


Output is the gain, k multiplied by the original transfer function. You can do more complex multiplications and parallel combinations, feedback arrangements, etc. with the various connections.

You could try this:

tf = TransferFunctionModel[{{1/s}}, s]
ClearAttributes[Times, Protected];
Times[k_, TransferFunctionModel[m_, s_]] :=
TransferFunctionModel[k m, s]
SetAttributes[Times, Protected];


But you would have to modify a lot of operations.

• Not feasible, IMO, because fundamental arithmetic operations are subject to special optimizations and can fail to apply (or lose completely) their user-defined rules at any moment. It would be better to make this definition on TransferFunctionModel than Times. – Oleksandr R. Jan 12 '15 at 12:04
• I tried that but got some complaints about a tag being nested too deep... – bdforbes Jan 12 '15 at 20:11