6
$\begingroup$

Consider this example.

M = TransferFunctionModel[3/(s^2 - s + 5), s]

the DC gain should be the value of the transfer function M[s] for s = 0, that is M[0] = 3/5.

But if I input the command (which was suggested in this answer: "How to convert a transfer function model to a zero-pole-gain model?")

Control`ZeroPoleGainModel[M]

this is the output from Mathematica:

Control`ZeroPoleGainModel[{{{{}}}, {1/2 (1 - i Sqrt[19]), 1/2 (1 + i Sqrt[19])}, {{3}}}, s] 

Note that the gain given by Mathematica is 3, whereas I was expecting 3/5.

What am I doing wrong here?

$\endgroup$
1
  • $\begingroup$ I'm having not a clue about TransferFunctionModel but did you see that the vector before {{3}} gives 5 if you multiply the complex numbers which are complements of each other? Maybe this is the scaling. $\endgroup$
    – halirutan
    Feb 27, 2017 at 4:45

3 Answers 3

7
$\begingroup$

The k in zpk is not the same as the dc gain. Given transfer function $\frac{num(s)}{den(s)}$, we write the tf in the form $k\frac{(s-z_1)(s-z_2)\dots}{(s-p₁)(s-p₂)\dots}$ where $z_{i}$ are the zeros of the numerator polynomial and $p_{i}$ are the zeros of the denominator polynomial.

The number which remains in the front, is the $k$. Sometimes called system gain, not to confuse it with dc gain.

In your example, the tf in zpk is simply $3 \frac{1}{(s-p_1)(s-p_2)}$ Since numerator polynomial is 1. There are only 2 poles. Hence $k=3$.

The dcgain, is step output at $t=\infty$. This is found as follows, using final value theorem

ClearAll[s, w];
tf = 3/(s^2 - s + 5);
stepOutput = tf * LaplaceTransform[UnitStep[t], t, s];
Limit[s stepOutput, s -> 0]

Mathematica graphics

btw, matlab has separate function called dcgain, as well as the zpk as Mathematica. Here is result from Matlab which agrees with Mathematica's

>> clear all
>> s=tf('s');
>> sys=3/(s^2-s+5);
>> dcgain(sys)

    0.6000

>> [z,p,k] = zpkdata(sys);
>> k

     3

You can see that dcgain is not the same as the $k$ in zpk.

$\endgroup$
2
  • $\begingroup$ Hi Nasser, I got your point. When in "zpk" mode, the gain of the system is $k$ which is not the DC gain, but it is just the $k$ factor multiplying $G(s)=k\frac{(s-z_{1})(s-z_{2})}{(s-p_{1})(s-p_{2})}$. The DC gain is found if $s=0$ and it is $G(0)=k\frac{z_{1}z_{2}}{p_{1}p_{2}}$. Thank you very much $\endgroup$
    – Lello
    Mar 2, 2017 at 0:15
  • $\begingroup$ note that $s = 0$ is the same as $t=\infty$ (final value theorem) $\endgroup$
    – Lello
    Apr 2, 2020 at 20:32
3
$\begingroup$

You can use Control`StaticGains

tf = 3/(s^2 - s + 5);
Control`StaticGains[TransferFunctionModel[tf, s]]

{{3/5}}

Or use the final value theorem

Limit[tf, s -> 0]

3/5

Nasser's answer already explains why StaticGains (or dc gain) is not the same as the gains in Control`ZeroPoleGainModel. The former is a system property, the latter is just an algebraic construct.

$\endgroup$
2
  • $\begingroup$ Is Control`StaticGains documented? $\endgroup$
    – user36273
    Feb 27, 2017 at 15:05
  • $\begingroup$ It's undocumented right now. That's why it's in the Control` context. $\endgroup$ Feb 27, 2017 at 15:27
2
$\begingroup$

Another way to determine the dc gain:

tf = TransferFunctionModel[3/(s^2 - s + 5), s];
{a, b, c, d} = Normal@StateSpaceModel[tf];
dcgain = -c.Inverse[a].b + d

{{3/5}}

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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