Cascade of state space models for linear systems I have two linear control system that are represented by their state space models
$$\left(
\begin{array}{c|c}
 A_1 & B_1 \\
\hline
 C_1 & D_1 \\
\end{array}
\right),
\left(
\begin{array}{c|c}
 A_2 & B_2 \\
\hline
 C_2 & D_2 \\
\end{array}
\right)$$
where $A_i$ is the state matrix, $B_i$ is the input matrix, $C_i$ is the output matrix and $D_i$ is the feedworward matrix.
The output of the first system is a vector signal of dimension $n$, which is the same dimension of the input signal of the second system. I want to put these two systems in cascade. How can I calculate the total space state model $(A_T, B_T, C_T, D_T)$?
 A: $$
(1) :\begin{cases}
\boldsymbol{\dot x}_1=\boldsymbol{A}_1 \boldsymbol{x}_1+\boldsymbol{B}_1 \boldsymbol{u}_1 \\
\boldsymbol{y}_1=\boldsymbol{C}_1 \boldsymbol{x}_1+\boldsymbol{D}_1 \boldsymbol{u}_1
\end{cases}
$$
$$
(2): 
\begin{cases}
\boldsymbol{\dot x}_2=\boldsymbol{A}_2 \boldsymbol{x}_2+\boldsymbol{B}_2 \boldsymbol{u}_2 \\
\boldsymbol{y}_2=\boldsymbol{C}_2 \boldsymbol{x}_2+\boldsymbol{D}_2 \boldsymbol{u}_2
\end{cases}
$$
I assume you mean the output of the first system is the input of the second system which means
$$
\boldsymbol{u}_2=\boldsymbol{y}_1
$$
Then you can reform the second system as 
$$
(2b)\begin{cases}
\boldsymbol{\dot x}_2=\boldsymbol{A}_2 \boldsymbol{x}_2+\boldsymbol{B}_2 (\boldsymbol{C}_1 \boldsymbol{x}_1+\boldsymbol{D}_1 \boldsymbol{u}_1) \\
\boldsymbol{y}_2=\boldsymbol{C}_2 \boldsymbol{x}_2+\boldsymbol{D}_2 (\boldsymbol{C}_1 \boldsymbol{x}_1+\boldsymbol{D}_1 \boldsymbol{u}_1)
\end{cases}
$$
Combining (1) and (2b):
$$
\begin{cases}
\boldsymbol{\dot x}_1=\boldsymbol{A}_1 \boldsymbol{x}_1+\boldsymbol{B}_1 \boldsymbol{u}_1 \\
\boldsymbol{\dot x}_2=\boldsymbol{A}_2 \boldsymbol{x}_2+\boldsymbol{B}_2 \boldsymbol{C}_1\boldsymbol{x}_1+\boldsymbol{B}_2 \boldsymbol{D}_1 \boldsymbol{u}_1 \\
\boldsymbol{y}_2=\boldsymbol{C}_2 \boldsymbol{x}_2+\boldsymbol{D}_2 \boldsymbol{C}_1 \boldsymbol{x}_1+\boldsymbol{D}_2\boldsymbol{D}_1 \boldsymbol{u}_1
\end{cases}
$$
Let's make it neat:
$$\begin{cases}
&\begin{bmatrix}\boldsymbol{\dot x}_1\\ \boldsymbol{\dot x}_2\end{bmatrix}&=\begin{bmatrix}
\boldsymbol{A}_1 & \boldsymbol{0}\\
\boldsymbol{B}_2\boldsymbol{C}_1 & \boldsymbol{A}_2
\end{bmatrix}\begin{bmatrix}\boldsymbol{x}_1\\\boldsymbol{x}_2\end{bmatrix}
+
\begin{bmatrix}
\boldsymbol{B}_1\\
\boldsymbol{B}_2\boldsymbol{D}_1
\end{bmatrix}\boldsymbol{u}_1    \\
&\boldsymbol{y}_2&=\begin{bmatrix}\boldsymbol{D}_2\boldsymbol{C}_1&\boldsymbol{C}_2\end{bmatrix}\begin{bmatrix}\boldsymbol{x}_1\\\boldsymbol{x}_2\end{bmatrix}+\begin{bmatrix}\boldsymbol{D}_2\boldsymbol{D}_1\end{bmatrix}\boldsymbol{u}_1
\end{cases}
$$
Compacting as a new system:
$$
\begin{cases}
\boldsymbol{\dot x}=\boldsymbol{A} \boldsymbol{x}+\boldsymbol{B} \boldsymbol{u} \\
\boldsymbol{y}=\boldsymbol{C} \boldsymbol{x}+\boldsymbol{D} \boldsymbol{u}
\end{cases}
$$
$$
\begin{align}
& \boldsymbol{A}=\begin{bmatrix}
\boldsymbol{A}_1 & \boldsymbol{0}\\
\boldsymbol{B}_2\boldsymbol{C}_1 & \boldsymbol{A}_2
\end{bmatrix}\\
& \boldsymbol{B}=\begin{bmatrix}
\boldsymbol{B}_1\\
\boldsymbol{B}_2\boldsymbol{D}_1
\end{bmatrix}\\
& \boldsymbol{C}=\begin{bmatrix}\boldsymbol{D}_2\boldsymbol{C}_1&\boldsymbol{C}_2\end{bmatrix} \\
& \boldsymbol{D}=\begin{bmatrix}\boldsymbol{D}_2\boldsymbol{D}_1\end{bmatrix}
\end{align}
$$
