跳到主要內容

[線性系統] 線性動態系統的表示法: 轉移函數 與 狀態空間表示

這次要介紹線性系統理論中對於動態系統的表示方法:
一般而言,線性動態系統 可以用 線性微分方程(O.D.E.) 來表達,但在控制理論中亦提供兩種不同的方法來表達動態系統:

一種稱為 轉移函數(transfer function) 表示法 (主要工具為 拉式轉換)
一種稱為 狀態空間(state space) 表示法 (主要工具為 矩陣線性代數)

那麼同一種 動態系統間,不同的表示法 可以互相等價轉換,現在我們先看個例子:

Example: Dynamic System to Transfer function
考慮下列動態系統微分方程
\[
\frac{{{d^3}y}}{{d{t^3}}} + 6\frac{{{d^2}y}}{{d{t^2}}} + 5\frac{{dy}}{{dt}} - 4y = u\left( t \right) + 2\frac{{du\left( t \right)}}{{dt}}
\] 那麼我們可以對其取拉式轉換(Laplace Transform) $\mathcal{L}(\cdot)$ 來求取轉移函數,亦即
\[\begin{array}{l}
{{\cal L}}\left\{ {\frac{{{d^3}y}}{{d{t^3}}} + 6\frac{{{d^2}y}}{{d{t^2}}} + 5\frac{{dy}}{{dt}} - 4y} \right\} = {{\cal L}}\left\{ {u\left( t \right) + 2\frac{{du\left( t \right)}}{{dt}}} \right\}\\
 \Rightarrow \left\{ \begin{array}{l}
{s^3}Y\left( s \right) - {s^2}y\left( 0 \right) - s{y^{\left( 1 \right)}}\left( 0 \right) - {y^{\left( 2 \right)}}\left( 0 \right)\\
 + 6\left( {{s^2}Y\left( s \right) - sy\left( 0 \right) - {y^{\left( 1 \right)}}\left( 0 \right)} \right)\\
 + 5\left( {sY\left( s \right) - y\left( 0 \right)} \right) \\
- 4Y\left( s \right)
\end{array} \right\} = \left\{ \begin{array}{l}
U\left( s \right)\\
 + 2\left( {sU\left( s \right) - u\left( 0 \right)} \right)
\end{array} \right\}
\end{array}
\] 上述中 $s$ 表示 微分器;反之 $s^{-1}$ 稱之為積分器。

現在考慮 $y^{(k)} =0, \forall k =0,1,2,...$ 且 $u(0) =0$ 亦即我們考慮整個動態系統的初始狀態為休止 (initially at rest),且亦無初始控制力,則上述拉式轉換式可得
\[\begin{array}{l}
{s^3}Y\left( s \right) + 6{s^2}Y\left( s \right) + 5sY\left( s \right) - 4Y\left( s \right) = U\left( s \right) + 2sU\left( s \right)\\
 \Rightarrow \left( {{s^3} + 6{s^2} + 5s - 4} \right)Y\left( s \right) = \left( {1 + 2s} \right)U\left( s \right)\\
 \Rightarrow \frac{{Y\left( s \right)}}{{U\left( s \right)}} = \frac{{ 2s + 1}}{{{s^3} + 6{s^2} + 5s - 4}}
\end{array}
\] 我們稱上述 $H(s) := \frac{Y(s)}{U(s)}$ 為轉移函數 transfer function。接著除了 轉移函數表示法之外,我們亦可將其用矩陣的方式表示:這邊僅簡單介紹可控典型式(controllable canonical form):
考慮上述轉移函數
\[H\left( s \right) = \frac{{Y\left( s \right)}}{{U\left( s \right)}} = \frac{{1 + 2s}}{{{s^3} + 6{s^2} + 5s - 4}}\]可將其改寫為以下狀態空間模型
\[\left\{ \begin{array}{l}
\dot x = Ax + Bu = \left[ {\begin{array}{*{20}{c}}
0&1&0\\
0&0&1\\
4&{ - 5}&{ - 6}
\end{array}} \right]\left[ {\begin{array}{*{20}{c}}
{{x_1}}\\
{{x_2}}\\
{{x_3}}
\end{array}} \right] + \left[ {\begin{array}{*{20}{c}}
0\\
0\\
1
\end{array}} \right]u\\
y = Cx = \left[ {\begin{array}{*{20}{c}}
1&2&0
\end{array}} \right]\left[ {\begin{array}{*{20}{c}}
{{x_1}}\\
{{x_2}}\\
{{x_3}}
\end{array}} \right]
\end{array} \right.\]

Comments:
1. 一般在 MATLAB中,建構轉移函數可以使用 tf(NUM,DEN) 指令,其中 NUM 表示分子係數,DEN表示分母係數:以上例而言,轉移函數透過 MATLAB 建構為

tf( [2 1], [1 6 5 -4])

2. 在MATLAB 中,如果已知轉移函數欲將其轉換到狀態空間模型 (亦即 欲得到 $A,B,C,D$ 矩陣) 有一個非常簡便的指令:[A,B,C,D] = tf2ss(NUM,DEN)



有了上述例子之後我們可以回頭看看 如何從 狀態空間模型 來 求得 轉移函數:

State-Space Method to Transfer Function

現在我們考慮狀態空間模型:
\[\left\{ \begin{array}{l}
\dot x = Ax + Bu\\
y = Cx + Du
\end{array} \right.
\]其中 $x$ 為 $n \times 1$狀態變數向量,$u$ 為 $m \times 1$ 控制力向量,$y$ 為 $r \times 1$ 輸出向量,$A$為 $n \times n$ 矩陣,$B$ 為 $n \times m$ 矩陣, $C$ 為 $r \times n$ 矩陣,$D$ 為 $r \times m $矩陣。

對上式取拉式轉換 $\cal{L}(\cdot)$ 並令初值為零,則可得
\[\left\{ \begin{array}{l}
sX\left( s \right) = AX\left( s \right) + BU\left( s \right)\\
Y\left( s \right) = CX\left( s \right) + DU\left( s \right)
\end{array} \right.
\]現在整理上式可得
\[\begin{array}{l}
\left\{ \begin{array}{l}
\left( {sI - A} \right)X\left( s \right) = BU\left( s \right)\\
Y\left( s \right) = CX\left( s \right) + DU\left( s \right)
\end{array} \right.\\
 \Rightarrow \left\{ \begin{array}{l}
X\left( s \right) = {\left( {sI - A} \right)^{ - 1}}BU\left( s \right)\\
Y\left( s \right) = CX\left( s \right) + DU\left( s \right)
\end{array} \right.\\
 \Rightarrow Y\left( s \right) = C{\left( {sI - A} \right)^{ - 1}}BU\left( s \right) + DU\left( s \right)\\
 \Rightarrow Y\left( s \right) = \left[ {C{{\left( {sI - A} \right)}^{ - 1}}B + D} \right]U\left( s \right)\\
 \Rightarrow \frac{{Y\left( s \right)}}{{U\left( s \right)}} = \underbrace {C{{\left( {sI - A} \right)}^{ - 1}}B + D}_{H\left( s \right)}
\end{array}
\]上述 $H(s)$ 即為轉移函數

且注意到
\[ \Rightarrow \frac{{Y\left( s \right)}}{{U\left( s \right)}} = \underbrace {C{{\left( {sI - A} \right)}^{ - 1}}B + D}_{H\left( s \right)} = C\frac{{adj\left( {sI - A} \right)}}{{\det \left( {sI - A} \right)}}B + D\]故 轉移函數 $H(s)$ 的分母等於 $\det (sI-A)$ 亦即 $\det(sI-A)=0$為系統特徵方程;且 $H(s)$ 的 pole 等於 $A$ 矩陣的 特徵值(eigenvalue)。


Comments:
1. 對線性動態系統而言,狀態空間表示法並非唯一 (故選取的 $A,B,C,D$ 矩陣稱為轉移函數的 實現 realization)。

2. 轉移函數 $H(s)$ 為唯一。亦即轉移函數具備不變性 (invariant).

3. 若 轉移函數 $H(s)$ 分母階數 $\ge$ 分子階數,我們稱此轉移函數為 proper。若 分母階數 $>$ 分子階數,則稱此轉移函數為 strictly proper。若 分母階數 $<$ 分子階數,稱此轉移函數為 improper。同理我們可直接對矩陣形式做判斷
\[ \Rightarrow \frac{{Y\left( s \right)}}{{U\left( s \right)}} = \underbrace {C{{\left( {sI - A} \right)}^{ - 1}}B + D}_{H\left( s \right)}\]若 $D=0$,則 $H(s)$ 為 stirctly proper ;若 $D \neq  0$ 則 $H(s)$ 並非 strictly proper。

對於上述 comments 有興趣的讀者請閱讀
 [線性系統] Realization Theory and Non-singular Transformation




Example 1.: The simplest improper transfer function
\[
H(s) = s
\]亦即,若轉移函數為一 微分器 ,則此時分母為常數 $1$,階數為0階 小於 分子 $s$ 的一階。故為 improper transfer function。

Example 2
考慮系統
\[\left\{ \begin{array}{l}
\dot x = Ax + Bu = \left[ {\begin{array}{*{20}{c}}
{ - 0.1}&1\\
0&{ - 1}
\end{array}} \right]x + \left[ {\begin{array}{*{20}{c}}
1\\
1
\end{array}} \right]u\\
y = Cx = \left[ {\begin{array}{*{20}{c}}
1&0
\end{array}} \right]x
\end{array} \right.
\](a) 試求 系統輸入輸出轉移函數。
(b) 若 $y(t) = 1 - {e^{ - t}}$ 且 $x(0)=0$ 試求對應的 $u(t)$。
Solution
(a):
\[\begin{array}{l}
\frac{{Y\left( s \right)}}{{U\left( s \right)}} = \underbrace {C{{\left( {sI - A} \right)}^{ - 1}}B + D}_{H\left( s \right)}\\
\begin{array}{*{20}{c}}
{}&{}&{}&{}
\end{array} = \left[ {\begin{array}{*{20}{c}}
1&0
\end{array}} \right]{\left( {\left[ {\begin{array}{*{20}{c}}
s&0\\
0&s
\end{array}} \right] - \left[ {\begin{array}{*{20}{c}}
{ - 0.1}&1\\
0&{ - 1}
\end{array}} \right]} \right)^{ - 1}}\left[ {\begin{array}{*{20}{c}}
1\\
1
\end{array}} \right] + 0\\
\begin{array}{*{20}{c}}
{}&{}&{}&{}
\end{array} = \left[ {\begin{array}{*{20}{c}}
1&0
\end{array}} \right]{\left[ {\begin{array}{*{20}{c}}
{s + 0.1}&{ - 1}\\
0&{s + 1}
\end{array}} \right]^{ - 1}}\left[ {\begin{array}{*{20}{c}}
1\\
1
\end{array}} \right]\\
\begin{array}{*{20}{c}}
{}&{}&{}&{}
\end{array} = \left[ {\begin{array}{*{20}{c}}
1&0
\end{array}} \right]\frac{1}{{\left( {s + 0.1} \right)\left( {s + 1} \right)}}\left[ {\begin{array}{*{20}{c}}
{s + 1}&1\\
0&{s + 0.1}
\end{array}} \right]\left[ {\begin{array}{*{20}{c}}
1\\
1
\end{array}} \right]\\
\begin{array}{*{20}{c}}
{}&{}&{}&{}
\end{array} = \frac{{s + 2}}{{\left( {s + 0.1} \right)\left( {s + 1} \right)}}
\end{array}\]
(b):由於 $y(t) = 1 - \frac{10}{9} e^{-t} + \frac{1}{9} e^{-10t}$ 對此取拉式轉換可得
\[y(t) = 1 - {e^{ - t}} \Rightarrow Y\left( s \right) = \frac{1}{s} - \frac{1}{{s + 1}}\]故由輸入與輸出關係
\[\begin{array}{l}
H\left( s \right) = \frac{{Y\left( s \right)}}{{U\left( s \right)}} = \frac{{s + 2}}{{\left( {s + 0.1} \right)\left( {s + 1} \right)}} \Rightarrow Y\left( s \right) = \frac{{s + 2}}{{\left( {s + 0.1} \right)\left( {s + 1} \right)}}U\left( s \right)\\
 \Rightarrow \frac{1}{s} - \frac{1}{{s + 1}} = \frac{{s + 2}}{{\left( {s + 0.1} \right)\left( {s + 1} \right)}}U\left( s \right)\\
 \Rightarrow U\left( s \right) = \frac{{\left( {s + 0.1} \right)\left( {s + 1} \right)}}{{s\left( {s + 2} \right)}} - \frac{{s + 0.1}}{{s + 2}}
\end{array}\]再取反拉式轉換即可求得所需結果。

留言

這個網誌中的熱門文章

[數學分析] 什麼是若且唯若 "if and only if"

數學上的 if and only if  ( 此文不討論邏輯學中的 if and only if,只討論數學上的 if and only if。) 中文翻譯叫做  若且唯若 (or 當且僅當) , 記得當初剛接觸這個詞彙的時候,我是完全不明白到底是甚麼意思,查了翻譯也是愛莫能助,畢竟有翻跟沒翻一樣,都是有看沒有懂。 在數學上如果看到 if and only if  這類的句子,其實是表示一種 雙條件句 ,通常可以直接將其視為" 定義(Definition)" 待之,今天要分享的是這樣的一個句子如何用比較直觀的方法去看他 假設我們現在有 兩個邏輯陳述句 A 與  B. 注意到,在此我們不必考慮這兩個陳述句到底是什麼,想表達什麼,或者到底是否為真(true),這些都不重要。只要知道是兩個陳述即可。 現在,考慮新的陳述:  "A if and only if B" 好了,現在主角登場,我們可以怎麼看待這個句子呢? 事實上我們可以很直覺的把這句子拆成兩部分看待,也就是 "( A if B ) and ( A only if B )" 那麼先針對第一個部分  A if B  來看, 其實這句就是說  if B then A, 更直白一點就是 "if B is true, then A is also true".  在數學上等價可以寫為 "B implies A" .  或者更常用一個箭頭符號來表示 "B $\Rightarrow$  A"  現在針對第二個部分  A only if B 此句意指  "If B is not true, then A is also not true". 所以如果已知 A is true,  那麼按照上句不難推得 B is also true 也就是說  A only if B  等價為 "If A is true then B is also true". 同樣,也可以寫作   "A implies B"   或者用箭頭表示  "A   $\Rightarrow$     B".

[數學分析] 淺談各種基本範數 (Norm)

這次要介紹的是數學上一個重要的概念: Norm: 一般翻譯成 範數 (在英語中 norm 有規範的意思,比如我們說normalization就是把某種東西/物品/事件 做 正規化,也就是加上規範使其正常化),不過個人認為其實翻譯成 範數 也是看不懂的...這邊建議把 Norm 想成長度就好 (事實上norm是長度的抽象推廣), 也許讀者會認為好端端的長度不用,為何又要發明一個 norm 來自討苦吃?? 既抽象又艱澀。 事實上想法是這樣的: 比如說現在想要比較兩個數字 $3$ , $5$ 之間的大小,則我們可以馬上知道 $ 3 < 5 $;同樣的,如果再考慮小數與無理數如 $1.8753$ 與 $\pi$,我們仍然可以比較大小 $1.8753 < \pi = 3.1415...$ 故可以發現我們有辦法對 "純量" 做明確的比大小,WHY? 因為前述例子中 $3$, $5$, $1.8753$ or $\pi$ 其各自的大小有辦法被 "measure "! 但是如果是現在考慮的是一組數字 我們如何去measure 其大小呢?? 比如說 \[x:=[1, -2, 0.1, 0 ]^T \]上式的大小該是多少? 是 $1$? $-2$? $0.1$??? 再者如果更過分一點,我們考慮一個矩陣 \[A = \left[ {\begin{array}{*{20}{c}} 1&2\\ 3&4 \end{array}} \right] \],想要知道這個矩陣的大小又該怎麼辦?? 是 $1$ ? $2$ 還是 $4$ ?..其實現階段我們說不清楚。 也正是如此,可以發現我們確實需要新的 "長度" 的定義來幫助我們如何去 measure 矩陣/向量/甚至是函數的大小。 故此,我們首先定義甚麼是Norm,(也就是把 "長度" or "大小" 的本質抽離出來) ================== Definition: Norm 考慮 $V$ 為一個向量空間(Vector space),則我們說  Norm 為一個函數 $||\cdot|| : V \rightarrow \mathbb{R}$ 且滿足下列性質