[Math] How should I interpret the static gain from MATLAB’s command zpkdata

control theorylinear-controlmatricesoptimal controltransformation

I was modeling a state space model and I was going to find the gain of the state space model.

My state space model looks like this:
$$
A = \begin{bmatrix}
-2 & -2\\
0 & -4
\end{bmatrix} \\
B = \begin{bmatrix}
1\\
1
\end{bmatrix}\\
C = \begin{bmatrix}
1 & 0
\end{bmatrix} \\
D = 0$$

If I set $s = 0$ in this equation:
$G(s) = C(sI-A)^{-1}B+D$

I can get the static gain. But when I use MATLAB

>> [z, p, k] = zpkdata(ss([-2 -2; 0 -4], [1;1], [1 0], [0]),'v')
z = [](0x1)
p = -4.0000
k =  1.00000

I get that the static gain k is 1.0. But this gives me another static gain:

$$G(s) = C(0I-A)^{-1}B+D = 0.25$$

Question:
Does this static gain k = 1.0 representing the static value for a transfer function? Or is that the gain k = 1.0 a gain for something else?

If I use MATLAB's command

>> zpk(z,p,k)

I will get

$$G(s) = \frac{1}{s+4}$$

And that is correct. But the gain here is not k = 1.0. How should I interpret k?

Best Answer

As mentioned by Johan Löfberg the gain you are interested in is defined as

$$ G(s) = K \frac{\prod (s - z_i)}{\prod (s - p_i)}. $$

For a SISO transfer function this $K$ can be found by dividing the coefficient of the highest powers of $s$ in the numerator by the coefficient of the highest powers of $s$ in the denominator. When a transfer function is given from a state space form

$$ G(s) = C\, (s\,I - A)^{-1} B + D $$

then the coefficient of the highest powers of $s$ in the denominator should be equal to one, because the denominator should be the determinant of $(s\,I - A)$. The numerators of $(s\,I - A)^{-1}$ always have a smaller order is $s$ then the determinant of $(s\,I - A)$. Therefore if $D \neq 0$ then the highest powers of $s$ in the numerator should match the highest powers of $s$ in the denominator. This then also implies that $K = D$.

If $D=0$ then it might get a little bit more complicated. I am not sure if this would be the most robust and efficient method but it should work. Namely if the state space model would be transformed into the controllable or observable canonical form then extracting the coefficients of the numerator should be straightforward. Namely for a state space model in the controllable canonical form the numerator coefficients should equal to $C$ when $D=0$. Therefore the gain $K$ should be equal to the first non-zero entry of $C$ starting from the right. In order or to convert a state space model into its controllable canonical form the following similarity transformation could be used

$$ \vec{v} = \begin{bmatrix} 0 & \cdots & 0 & 1 \end{bmatrix} \begin{bmatrix} B & A\,B & \cdots & A^{n-1} B \end{bmatrix}^{-1}, $$

$$ T = \begin{bmatrix} \vec{v} \\ \vec{v}\,A \\ \vdots \\ \vec{v}\,A^{n-1} \end{bmatrix}. $$

For more detail see this question. The new $C$ matrix in the controllable canonical form is then given by

$$ C_\text{ctrb} = C\,T^{-1}. $$

It can be noted that this method only works if the system is controllable, since the inverse of the controllability matrix is used.


When applying this method to your example state space model one gets that the controllability matrix is not full rank. However the observability matrix is full rank, so will use the dual system instead of finding the controllable and observable part of the system. This changes the equations into

$$ \vec{v} = \begin{bmatrix} C \\ C\,A \\ \vdots \\ C\,A^{n-1} \end{bmatrix}^{-1} \begin{bmatrix} 0 \\ \vdots \\ 0 \\ 1 \end{bmatrix} = \begin{bmatrix} 1 & 0 \\ -2 & -2 \end{bmatrix}^{-1} \begin{bmatrix} 0 \\ 1 \end{bmatrix} = \begin{bmatrix} 0 \\ -\frac{1}{2} \end{bmatrix}, $$

$$ T = \begin{bmatrix} \vec{v} & A\,\vec{v} & \cdots & A^{n-1} \vec{v} \end{bmatrix} = \begin{bmatrix} 0 & 1 \\ -\frac{1}{2} & 2 \end{bmatrix}, $$

$$ C_\text{ctrb} = B^\top T^{-\top} = \begin{bmatrix} 2 & 1 \end{bmatrix}. $$

The first non-zero entry of $C_\text{ctrb}$ starting from the right is $1$, so therefore $K=1$. If the state space model would be both uncontrollable and unobservable, then first the minimal space space realization would be required for this method. In that case it might just be faster to evaluate $G(s)$ and look at the resulting numerator coefficients.