Bode of Controller and Sensitivity Functions in a State Feedback Controller System I have a system:  

$A$, $B$ and $C$ forms the state space representation of the system. The system has a state feed back controller with an integral controller. I want to draw bode plot of controller, sensitivity function and complementary sensitivity function. How can I create these plots from a system like this? I know that sensitivity function is defined as $1/(1+PC)$ but I can not define $P$ and $C$ in this system; it is same in other two plots.
 A: The open loop $P\,C$ can not be defined when you are using cascading control and you want the open loop to be a SISO system. You could define a MIMO open loop using
\begin{align}
\begin{bmatrix}
\dot{x} \\ \dot{x}_i
\end{bmatrix} &= 
\begin{bmatrix}
A & -B\,K_i \\ 0 & 0
\end{bmatrix}
\begin{bmatrix}
x \\ x_i
\end{bmatrix} + 
\begin{bmatrix}
B\,K & 0 \\ 0 & I
\end{bmatrix}v \\
y &= \begin{bmatrix}
I & 0 \\ C & 0
\end{bmatrix}
\begin{bmatrix}
x \\ x_i
\end{bmatrix},
\end{align}
with in closed loop $v = \vec{r} - y$ where $\vec{r} = \begin{bmatrix}r_x^\top & r^\top \end{bmatrix}^\top$, so in order to get the same closed loop you would have to set $r_x=0$. I do have to note that the order of multiplication matters when calculating the transfer functions that you are interested, since you are dealing with a MIMO open loop which is a (transfer function) matrix and does not commute.
Another approach is to add an observer and use the error $e=r-y$ instead of the output to estimate the state. In that case only the output of the system will be used in the feedback loop and is $e$ the only input to the controller. Normally the observer dynamics is defined as
$$
\dot{\hat{x}} = A\,\hat{x} + B\,u + L(y - C\,\hat{x}),
$$
such that the combined closed loop dynamics can be written as
$$
\begin{bmatrix}
\dot{x} \\ \dot{\hat{x}} \\ \dot{x}_i
\end{bmatrix} = 
\begin{bmatrix}
A & -B\,K & -B\,K_i \\
L\,C & A-B\,K-L\,C & -B\,K_i \\
-C & 0 & 0
\end{bmatrix}
\begin{bmatrix}
x \\ \hat{x} \\ x_i
\end{bmatrix} +
\begin{bmatrix}
0 \\ 0 \\ I
\end{bmatrix} r.
$$
But if $-e=y-r$ is used instead of $y$ in $\dot{\hat{x}}$ then the closed loop dynamics becomes
$$
\begin{bmatrix}
\dot{x} \\ \dot{\hat{x}} \\ \dot{x}_i
\end{bmatrix} = 
\begin{bmatrix}
A & -B\,K & -B\,K_i \\
L\,C & A-B\,K-L\,C & -B\,K_i \\
-C & 0 & 0
\end{bmatrix}
\begin{bmatrix}
x \\ \hat{x} \\ x_i
\end{bmatrix} +
\begin{bmatrix}
0 \\ -L \\ I
\end{bmatrix} r,
$$
so the same system matrix but a different input matrix, therefore the closed loop poles will be the same, but the zeros might be different. The open loop then becomes
\begin{align}
\begin{bmatrix}
\dot{x} \\ \dot{\hat{x}} \\ \dot{x}_i
\end{bmatrix} &= 
\begin{bmatrix}
A & -B\,K & -B\,K_i \\
0 & A-B\,K-L\,C & -B\,K_i \\
0 & 0 & 0
\end{bmatrix}
\begin{bmatrix}
x \\ \hat{x} \\ x_i
\end{bmatrix} +
\begin{bmatrix}
0 \\ -L \\ I
\end{bmatrix} e \\
y &= \begin{bmatrix}
C & 0 & 0
\end{bmatrix}
\begin{bmatrix}
x \\ \hat{x} \\ x_i
\end{bmatrix}.
\end{align}
