# 狀態空間

想搵電腦科學嘅狀態空間嘅話，請睇狀態空間 (電腦科學)

## 狀態變數

${\displaystyle \mathbf {x} (t)=\mathbf {\Phi } (t)\mathbf {x} _{0}}$

${\displaystyle \mathbf {x} (t)=\mathbf {x} _{0}+\int \limits _{0}^{t}\mathbf {f} (\mathbf {x} (\tau ))d\tau }$，其中${\displaystyle {\dot {\mathbf {x} }}=\mathbf {f} (\mathbf {x} )}$

${\displaystyle \mathbf {x^{0}} (t)=\mathbf {x} _{0}}$
${\displaystyle \mathbf {x^{k}} (t)=\mathbf {x} _{0}+\int \limits _{0}^{t}\mathbf {f^{k-1}} (\mathbf {x} (\tau ))d\tau }$

## 線性系統

### 基本形式

${\displaystyle {\dot {\mathbf {x} }}(t)=\mathbf {A} (t)\mathbf {x} (t)+\mathbf {B} (t)\mathbf {u} (t)}$
${\displaystyle \mathbf {y} (t)=\mathbf {C} (t)\mathbf {x} (t)+\mathbf {D} (t)\mathbf {u} (t)}$

${\displaystyle \mathbf {x} (\cdot )}$係「狀態向量」，${\displaystyle \mathbf {x} (t)\in \mathbb {R} ^{n}}$ ;
${\displaystyle \mathbf {y} (\cdot )}$係「輸出向量」，${\displaystyle \mathbf {y} (t)\in \mathbb {R} ^{q}}$ ;
${\displaystyle \mathbf {u} (\cdot )}$係「輸入向量」（又叫「控制向量」），${\displaystyle \mathbf {u} (t)\in \mathbb {R} ^{p}}$ ;
${\displaystyle \mathbf {A} (\cdot )}$係「狀態矩陣」（又叫「系統矩陣」），${\displaystyle \operatorname {dim} [\mathbf {A} (\cdot )]=n\times n}$
${\displaystyle \mathbf {B} (\cdot )}$係「輸入矩陣」，${\displaystyle \operatorname {dim} [\mathbf {B} (\cdot )]=n\times p}$
${\displaystyle \mathbf {C} (\cdot )}$係「輸出矩陣」，${\displaystyle \operatorname {dim} [\mathbf {C} (\cdot )]=q\times n}$
${\displaystyle \mathbf {D} (\cdot )}$係「饋通矩陣」（又叫「前饋矩陣」）（喺系統模型冇直接饋通嘅情況下， ${\displaystyle \mathbf {D} (\cdot )}$係零矩陣），${\displaystyle \operatorname {dim} [\mathbf {D} (\cdot )]=q\times p}$
${\displaystyle {\dot {\mathbf {x} }}(t):={\frac {\operatorname {d} }{\operatorname {d} t}}\mathbf {x} (t)}$

${\displaystyle \mathbf {\Phi } (t)=e^{\mathbf {A} t}}$
${\displaystyle \mathbf {x} (t)=e^{\mathbf {A} t}\mathbf {x} _{0}}$

${\displaystyle \mathbf {\hat {\Phi }} (s)=(s\mathbf {I} -\mathbf {A} )^{-1}}$
${\displaystyle \mathbf {X} (s)=(s\mathbf {I} -\mathbf {A} )^{-1}\mathbf {x} _{0}}$

 系統類型 狀態空間模型 連續時唔變 ${\displaystyle {\dot {\mathbf {x} }}(t)=\mathbf {A} \mathbf {x} (t)+\mathbf {B} \mathbf {u} (t)}$${\displaystyle \mathbf {y} (t)=\mathbf {C} \mathbf {x} (t)+\mathbf {D} \mathbf {u} (t)}$ 連續時變 ${\displaystyle {\dot {\mathbf {x} }}(t)=\mathbf {A} (t)\mathbf {x} (t)+\mathbf {B} (t)\mathbf {u} (t)}$${\displaystyle \mathbf {y} (t)=\mathbf {C} (t)\mathbf {x} (t)+\mathbf {D} (t)\mathbf {u} (t)}$ 顯式離散時唔變 ${\displaystyle \mathbf {x} (k+1)=\mathbf {A} \mathbf {x} (k)+\mathbf {B} \mathbf {u} (k)}$${\displaystyle \mathbf {y} (k)=\mathbf {C} \mathbf {x} (k)+\mathbf {D} \mathbf {u} (k)}$ 顯式離散時變 ${\displaystyle \mathbf {x} (k+1)=\mathbf {A} (k)\mathbf {x} (k)+\mathbf {B} (k)\mathbf {u} (k)}$${\displaystyle \mathbf {y} (k)=\mathbf {C} (k)\mathbf {x} (k)+\mathbf {D} (k)\mathbf {u} (k)}$ 連續時唔變個拉普拉斯域 ${\displaystyle s\mathbf {X} (s)-\mathbf {x} (0)=\mathbf {A} \mathbf {X} (s)+\mathbf {B} \mathbf {U} (s)}$${\displaystyle \mathbf {Y} (s)=\mathbf {C} \mathbf {X} (s)+\mathbf {D} \mathbf {U} (s)}$ 離散時唔變個Z域 ${\displaystyle z\mathbf {X} (z)-z\mathbf {x} (0)=\mathbf {A} \mathbf {X} (z)+\mathbf {B} \mathbf {U} (z)}$${\displaystyle \mathbf {Y} (z)=\mathbf {C} \mathbf {X} (z)+\mathbf {D} \mathbf {U} (z)}$

#### 例：連續時間LTI系統

${\displaystyle {\textbf {G}}(s)=k{\frac {(s-z_{1})(s-z_{2})(s-z_{3})}{(s-p_{1})(s-p_{2})(s-p_{3})(s-p_{4})}}.}$

${\displaystyle \lambda (s)=|s\mathbf {I} -\mathbf {A} |.}$

### 系統性質

#### 可控性

${\displaystyle \operatorname {rank} {\begin{bmatrix}\mathbf {B} &\mathbf {A} \mathbf {B} &\mathbf {A} ^{2}\mathbf {B} &\dots &\mathbf {A} ^{n-1}\mathbf {B} \end{bmatrix}}=n,}$

1. ${\displaystyle \mathbf {B} }$陣啲行唔係全零行；
2. 同特徵值嘅Jordan塊，對應${\displaystyle \mathbf {B} }$陣嘅嗰啲行互相之間線性無關。

#### 可觀察性

${\displaystyle \operatorname {rank} {\begin{bmatrix}\mathbf {C} \\\mathbf {C} \mathbf {A} \\\vdots \\\mathbf {C} \mathbf {A} ^{n-1}\end{bmatrix}}=n.}$

1. ${\displaystyle \mathbf {C} }$陣啲列唔係全零列；
2. 同特徵值嘅Jordan塊，對應${\displaystyle \mathbf {C} }$陣嘅嗰啲列互相之間線性無關。

#### 穩定性

BIBO穩定性關注系統嘅零狀態響應，而平衡穩定性關注系統嘅零輸入響應。其中，Lyapunov穩定性係動力系統穩定性理論嘅基礎。穩定性嘅確定同狀態矩陣A密切相關。

##### BIBO穩定性

BIBO穩定性代表輸入有界嗰陣輸出都係有界嘅。呢個可以當作係啲唔穩定極點俾零抵消嗮嘅情況。

##### 漸近穩定性

${\displaystyle \|x(t_{0})\|<\delta (t_{0})\Rightarrow \lim _{t\to \infty }\|x(t)\|=0}$

LTI系統漸近穩定嘅充要條件係系統嘅所有特徵值（ A嘅特徵值）都擁有負實部。

### 遞移函數

${\displaystyle {\dot {\mathbf {x} }}(t)=\mathbf {A} \mathbf {x} (t)+\mathbf {B} \mathbf {u} (t)}$

${\displaystyle s\mathbf {X} (s)-\mathbf {x} (0)=\mathbf {A} \mathbf {X} (s)+\mathbf {B} \mathbf {U} (s).}$

${\displaystyle (s\mathbf {I} -\mathbf {A} )\mathbf {X} (s)=\mathbf {x} (0)+\mathbf {B} \mathbf {U} (s)}$

${\displaystyle \mathbf {X} (s)=(s\mathbf {I} -\mathbf {A} )^{-1}\mathbf {x} (0)+(s\mathbf {I} -\mathbf {A} )^{-1}\mathbf {B} \mathbf {U} (s).}$

${\displaystyle \mathbf {X} (s)}$入個輸出方程式

${\displaystyle \mathbf {Y} (s)=\mathbf {C} \mathbf {X} (s)+\mathbf {D} \mathbf {U} (s),}$

${\displaystyle \mathbf {Y} (s)=\mathbf {C} ((s\mathbf {I} -\mathbf {A} )^{-1}\mathbf {x} (0)+(s\mathbf {I} -\mathbf {A} )^{-1}\mathbf {B} \mathbf {U} (s))+\mathbf {D} \mathbf {U} (s).}$

${\displaystyle \mathbf {Y} (s)=\mathbf {G} (s)\mathbf {U} (s)}$

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

### 典範實現

${\displaystyle {\textbf {G}}(s)={\frac {n_{1}s^{3}+n_{2}s^{2}+n_{3}s+n_{4}}{s^{4}+d_{1}s^{3}+d_{2}s^{2}+d_{3}s+d_{4}}}.}$

${\displaystyle {\dot {\textbf {x}}}(t)={\begin{bmatrix}0&1&0&0\\0&0&1&0\\0&0&0&1\\-d_{4}&-d_{3}&-d_{2}&-d_{1}\end{bmatrix}}{\textbf {x}}(t)+{\begin{bmatrix}0\\0\\0\\1\\\end{bmatrix}}{\textbf {u}}(t)}$
${\displaystyle {\textbf {y}}(t)={\begin{bmatrix}n_{4}&n_{3}&n_{2}&n_{1}\end{bmatrix}}{\textbf {x}}(t).}$

${\displaystyle {\dot {\textbf {x}}}(t)={\begin{bmatrix}0&0&0&-d_{4}\\1&0&0&-d_{3}\\0&1&0&-d_{2}\\0&0&1&-d_{1}\end{bmatrix}}{\textbf {x}}(t)+{\begin{bmatrix}n_{4}\\n_{3}\\n_{2}\\n_{1}\end{bmatrix}}{\textbf {u}}(t)}$
${\displaystyle {\textbf {y}}(t)={\begin{bmatrix}0&0&0&1\end{bmatrix}}{\textbf {x}}(t).}$

### 真分遞移函數

${\displaystyle {\textbf {G}}(s)={\textbf {G}}_{\mathrm {SP} }(s)+{\textbf {G}}(\infty ).}$

${\displaystyle {\textbf {G}}(s)={\frac {s^{2}+3s+3}{s^{2}+2s+1}}={\frac {s+2}{s^{2}+2s+1}}+1}$

${\displaystyle {\dot {\textbf {x}}}(t)={\begin{bmatrix}-2&-1\\1&0\\\end{bmatrix}}{\textbf {x}}(t)+{\begin{bmatrix}1\\0\end{bmatrix}}{\textbf {u}}(t)}$
${\displaystyle {\textbf {y}}(t)={\begin{bmatrix}1&2\end{bmatrix}}{\textbf {x}}(t)+{\begin{bmatrix}1\end{bmatrix}}{\textbf {u}}(t)}$

### 回輸

${\displaystyle {\dot {\mathbf {x} }}(t)=A\mathbf {x} (t)+B\mathbf {u} (t)}$
${\displaystyle \mathbf {y} (t)=C\mathbf {x} (t)+D\mathbf {u} (t)}$

${\displaystyle {\dot {\mathbf {x} }}(t)=A\mathbf {x} (t)+BK\mathbf {y} (t)}$
${\displaystyle \mathbf {y} (t)=C\mathbf {x} (t)+DK\mathbf {y} (t)}$

${\displaystyle {\dot {\mathbf {x} }}(t)=\left(A+BK\left(I-DK\right)^{-1}C\right)\mathbf {x} (t)}$
${\displaystyle \mathbf {y} (t)=\left(I-DK\right)^{-1}C\mathbf {x} (t)}$

#### 例子

${\displaystyle {\dot {\mathbf {x} }}(t)=\left(A+BK\right)\mathbf {x} (t)}$
${\displaystyle \mathbf {y} (t)=\mathbf {x} (t)}$

### 帶設定值（參考值）輸入嘅回輸

${\displaystyle {\dot {\mathbf {x} }}(t)=A\mathbf {x} (t)+B\mathbf {u} (t)}$
${\displaystyle \mathbf {y} (t)=C\mathbf {x} (t)+D\mathbf {u} (t)}$

${\displaystyle {\dot {\mathbf {x} }}(t)=A\mathbf {x} (t)-BK\mathbf {y} (t)+B\mathbf {r} (t)}$
${\displaystyle \mathbf {y} (t)=C\mathbf {x} (t)-DK\mathbf {y} (t)+D\mathbf {r} (t)}$

${\displaystyle {\dot {\mathbf {x} }}(t)=\left(A-BK\left(I+DK\right)^{-1}C\right)\mathbf {x} (t)+B\left(I-K\left(I+DK\right)^{-1}D\right)\mathbf {r} (t)}$
${\displaystyle \mathbf {y} (t)=\left(I+DK\right)^{-1}C\mathbf {x} (t)+\left(I+DK\right)^{-1}D\mathbf {r} (t)}$

${\displaystyle {\dot {\mathbf {x} }}(t)=\left(A-BKC\right)\mathbf {x} (t)+B\mathbf {r} (t)}$
${\displaystyle \mathbf {y} (t)=C\mathbf {x} (t)}$

### 運動對象示例

${\displaystyle m{\ddot {y}}(t)=u(t)-b{\dot {y}}(t)-ky(t)}$

• ${\displaystyle y(t)}$係位置；${\displaystyle {\dot {y}}(t)}$係速度；${\displaystyle {\ddot {y}}(t)}$係加速度
• ${\displaystyle u(t)}$係施加嘅力
• ${\displaystyle b}$係黏性摩擦係數
• ${\displaystyle k}$係彈簧係數
• ${\displaystyle m}$係件嘢嘅質量

${\displaystyle \left[{\begin{matrix}\mathbf {{\dot {x}}_{1}} (t)\\\mathbf {{\dot {x}}_{2}} (t)\end{matrix}}\right]=\left[{\begin{matrix}0&1\\-{\frac {k}{m}}&-{\frac {b}{m}}\end{matrix}}\right]\left[{\begin{matrix}\mathbf {x_{1}} (t)\\\mathbf {x_{2}} (t)\end{matrix}}\right]+\left[{\begin{matrix}0\\{\frac {1}{m}}\end{matrix}}\right]\mathbf {u} (t)}$
${\displaystyle \mathbf {y} (t)=\left[{\begin{matrix}1&0\end{matrix}}\right]\left[{\begin{matrix}\mathbf {x_{1}} (t)\\\mathbf {x_{2}} (t)\end{matrix}}\right]}$

• ${\displaystyle x_{1}(t)}$代表件嘢嘅位置
• ${\displaystyle x_{2}(t)={\dot {x}}_{1}(t)}$係件嘢嘅速度
• ${\displaystyle {\dot {x}}_{2}(t)={\ddot {x}}_{1}(t)}$係件嘢嘅加速度
• 輸出${\displaystyle \mathbf {y} (t)}$係件嘢嘅位置

${\displaystyle \left[{\begin{matrix}B&AB\end{matrix}}\right]=\left[{\begin{matrix}\left[{\begin{matrix}0\\{\frac {1}{m}}\end{matrix}}\right]&\left[{\begin{matrix}0&1\\-{\frac {k}{m}}&-{\frac {b}{m}}\end{matrix}}\right]\left[{\begin{matrix}0\\{\frac {1}{m}}\end{matrix}}\right]\end{matrix}}\right]=\left[{\begin{matrix}0&{\frac {1}{m}}\\{\frac {1}{m}}&-{\frac {b}{m^{2}}}\end{matrix}}\right]}$

${\displaystyle \left[{\begin{matrix}C\\CA\end{matrix}}\right]=\left[{\begin{matrix}\left[{\begin{matrix}1&0\end{matrix}}\right]\\\left[{\begin{matrix}1&0\end{matrix}}\right]\left[{\begin{matrix}0&1\\-{\frac {k}{m}}&-{\frac {b}{m}}\end{matrix}}\right]\end{matrix}}\right]=\left[{\begin{matrix}1&0\\0&1\end{matrix}}\right]}$

## 非線性系統

${\displaystyle \mathbf {\dot {x}} (t)=\mathbf {f} (t,x(t),u(t))}$
${\displaystyle \mathbf {y} (t)=\mathbf {h} (t,x(t),u(t))}$

### 擺嘅例子

${\displaystyle m\ell ^{2}{\ddot {\theta }}(t)=-m\ell g\sin \theta (t)-k\ell {\dot {\theta }}(t)}$

• ${\displaystyle \theta (t)}$係件擺戥重力方向嘅角度
• ${\displaystyle m}$係件擺嘅質量（假設條擺桿嘅質量為零）
• ${\displaystyle g}$係重力加速度
• ${\displaystyle k}$係鉸口嘅摩擦係數
• ${\displaystyle \ell }$係件擺嘅半徑（表面到質量${\displaystyle m}$嘅重心）

${\displaystyle {\dot {x}}_{1}(t)=x_{2}(t)}$
${\displaystyle {\dot {x}}_{2}(t)=-{\frac {g}{\ell }}\sin {x_{1}}(t)-{\frac {k}{m\ell }}{x_{2}}(t)}$

• ${\displaystyle x_{1}(t)=\theta (t)}$係件擺嘅角度
• ${\displaystyle x_{2}(t)={\dot {x}}_{1}(t)}$係件擺嘅角速度
• ${\displaystyle {\dot {x}}_{2}={\ddot {x}}_{1}}$係件擺嘅角加速度

${\displaystyle {\dot {\mathbf {x} }}(t)=\left({\begin{matrix}{\dot {x}}_{1}(t)\\{\dot {x}}_{2}(t)\end{matrix}}\right)=\mathbf {f} (t,x(t))=\left({\begin{matrix}x_{2}(t)\\-{\frac {g}{\ell }}\sin {x_{1}}(t)-{\frac {k}{m\ell }}{x_{2}}(t)\end{matrix}}\right).}$

${\displaystyle \left({\begin{matrix}x_{1}\\x_{2}\\{\dot {x}}_{2}\end{matrix}}\right)=\left({\begin{matrix}n\pi \\0\\0\end{matrix}}\right)}$

## 考

1. Katalin M. Hangos; R. Lakner; M. Gerzson (2001). Intelligent Control Systems: An Introduction with Examples. Springer. p. 254. ISBN 978-1-4020-0134-5.
2. Katalin M. Hangos; József Bokor; Gábor Szederkényi (2004). Analysis and Control of Nonlinear Process Systems. Springer. p. 25. ISBN 978-1-85233-600-4.
3. Vasilyev A.S.; Ushakov A.V. (2015). "Modeling of dynamic systems with modulation by means of Kronecker vector-matrix representation". Scientific and Technical Journal of Information Technologies, Mechanics and Optics. 15 (5): 839–848. doi:10.17586/2226-1494-2015-15-5-839-848.
4. Roesser, R. (1975). "A discrete state-space model for linear image processing". IEEE Transactions on Automatic Control. 20 (1): 1–10. doi:10.1109/tac.1975.1100844. ISSN 0018-9286.
5. Stock, J.H.; Watson, M.W. (2016), "Dynamic Factor Models, Factor-Augmented Vector Autoregressions, and Structural Vector Autoregressions in Macroeconomics", Handbook of Macroeconomics (英文), Elsevier, 2: 415–525, doi:10.1016/bs.hesmac.2016.04.002, ISBN 978-0-444-59487-7
6. Durbin, James; Koopman, Siem Jan (2012). Time series analysis by state space methods. Oxford University Press. ISBN 978-0-19-964117-8. OCLC 794591362.
7. Smith, Anne C.; Brown, Emery N. (2003). "Estimating a State-Space Model from Point Process Observations". Neural Computation. 15 (5): 965–991. doi:10.1162/089976603765202622. ISSN 0899-7667. PMID 12803953.
8. James H. Stock & Mark W. Watson, 1989. "New Indexes of Coincident and Leading Economic Indicators," NBER Chapters, in: NBER Macroeconomics Annual 1989, Volume 4, pages 351-409, National Bureau of Economic Research, Inc.
9. Bańbura, Marta; Modugno, Michele (2012-11-12). "Maximum Likelihood Estimation of Factor Models on Datasets with Arbitrary Pattern of Missing Data". Journal of Applied Econometrics. 29 (1): 133–160. doi:10.1002/jae.2306. ISSN 0883-7252. {{cite journal}}: |hdl-access= requires |hdl= (help)
10. "State-Space Models with Markov Switching and Gibbs-Sampling", State-Space Models with Regime Switching, The MIT Press, 2017, doi:10.7551/mitpress/6444.003.0013, ISBN 978-0-262-27711-2
11. Kalman, R. E. (1960-03-01). "A New Approach to Linear Filtering and Prediction Problems". Journal of Basic Engineering (英文). 82 (1): 35–45. doi:10.1115/1.3662552. ISSN 0021-9223.
12. Harvey, Andrew C. (1990). Forecasting, Structural Time Series Models and the Kalman Filter. Cambridge: Cambridge University Press. doi:10.1017/CBO9781107049994
13. Nise, Norman S. (2010). Control Systems Engineering (第6版). John Wiley & Sons, Inc. ISBN 978-0-470-54756-4.
14. Brogan, William L. (1974). Modern Control Theory (第1版). Quantum Publishers, Inc. p. 172.

## 進一步閱讀

On the applications of state-space models in econometrics
• Durbin, J.; Koopman, S. (2001). Time series analysis by state space methods. Oxford, UK: Oxford University Press. ISBN 978-0-19-852354-3.