# How do I compute/plot the open loop transfer function of a system given its state-space description?

Suppose I have a dynamical system with a continuous time state-space description given by the matrices A, B, C, and D, under full-state feedback u=Kx (where x is the state and x is the control input).

How do I compute the Bode plot of the open-loop system, as I would do in traditional frequency-domain analysis?

As a simple, concrete example, consider the problem where the plant is a mass on a spring, on which I can exert a force $F_{ext}$. Suppose I use a PID controller to control the position of the mass.

A state space description of the plant (with an adjoined integrator state to be used by the controller) is:

A = [0, 1, 0; -k, -g, 0; 1, 0, 0];
B = [0; 1/m; 0];


And the PID controller can be realized through full-state feedback with the matrix:

K = [kp, kd, ki];


Meanwhile, in the frequency domain, the plant has transfer function $G(s)$, and the controller has transfer function $H(s) = k_p + \frac{1}{s} k_i + s k_d$.

In frequency domain analysis, the transfer function $GH$, the open loop transfer function is of interest. This is what we example, for example, to determine gain margin and phase margin.

How do I obtain $GH$ given $A, B, C, D$ and $K$?

## 1 Answer

In order for the open loop to be meaningful the input to the controller has to have the same dimensions and units as the output of the plant, since normally when doing control in the frequency domain using unity negative feedback the input to the controller is defined as the error signal (reference signal minus the output of the plant). But if the full state is not measured (in the output of the plant) then you can not recreate the 'state' from the error signal directly. Instead you would have to use an observer, which normally is defined as

$$\dot{\hat{x}} = A\,\hat{x} + B\,u + L\,(y - C\,\hat{x} - D\,u)$$

where $\hat{x}$ is the estimate of the state, $L$ is a matrix such that $A-L\,C$ is Hurwitz and $y$ the output of the actual plant. When using full state feedback then $u = -K\,\hat{x}$. However in the case of the open loop $y$ will be replaced by minus the error signal $-e = y-r$, such that when $r=0$ then it is equivalent as the equation above. Combining this white the dynamics of the plant yields

\begin{align} \begin{bmatrix} \dot{x} \\ \dot{\hat{x}} \end{bmatrix} &= \underbrace{ \begin{bmatrix} A & -B\,K \\ 0 & A - B\,K - L\,C + L\,D\,K \end{bmatrix}}_{A_{ol}} \begin{bmatrix} x \\ \hat{x} \end{bmatrix} + \underbrace{ \begin{bmatrix} 0 \\ -L \end{bmatrix}}_{B_{ol}} e \\ y &= \underbrace{ \begin{bmatrix} C & -D\,K \end{bmatrix}}_{C_{ol}} \begin{bmatrix} x \\ \hat{x} \end{bmatrix} \end{align}

Due to the way the observer is defined the 'controller' (the effective transfer function which gets multiplied by the plant) will always have a strictly proper transfer function. So even if a constant gain might be sufficient for control, this general method will always add some sort of low-pass filter to the controller as well.

This state space model can be converted to an equivalent transfer function using

$$G_{ol}(s) = C_{ol}\,(s\,I - A_{ol})^{-1}\,B_{ol}.$$

You could also calculate the points of the Bode plot directly by substituting $s = j\,\omega$, with $\omega$ the desired frequencies (in radians per second) for your Bode plot.

It can be noted that in the case of your example system the integral state will not be observable. But it can be an option to first filter the error signal with $\begin{bmatrix}1 & 1/s\end{bmatrix}^\top$ before passing it through $G_{ol}(s)$, and use for the observer in $G_{ol}(s)$ that both the position and the integral are measured.

• Hmm, I think that's part of the story, but we still have to incorporate the feedback law u=Kx. – nibot May 11 '18 at 5:10
• @nibot In your question you asked about the Bode plot of the open-loop system. By definition when you use a feedback law ($u = K\,x$) you are not dealing with the open-loop system. Also if did meant the system with feedback, how would you define the input of the system, since the normal input is already defined as $u = K\,x$? – fibonatic May 11 '18 at 5:41
• I added some additional material to the question that should make it more clear. – nibot May 11 '18 at 16:10
• @nibot I have updated my answer. – fibonatic May 14 '18 at 9:20