138.1 Setting up the problem
- In the prior lesson, you learned that
\Sigma_{\bar{w}} = \int_{0}^{\Delta t} e^{A(\Delta t-\tau)} B_w S_w B_w^T e^{A^T(\Delta t-\tau)} \, d\tau .
- But how do we compute this exactly?
- You learned that if \Delta t \to 0, then \Sigma_{\bar{w}} \approx B_w S_w B_w^T
- But how do we find \Sigma_{\bar{w}} precisely for general \Delta t? Assume that we know S_w and the plant dynamics.
- Define
Z = \begin{bmatrix} -A & B_w S_w B_w^T \\ 0 & A^T \end{bmatrix}, \qquad C = e^{Z \Delta t} = \begin{bmatrix} c_{11} & c_{12} \\ 0 & c_{22} \end{bmatrix}.
138.2 Computing C
- We seek to compute C = \mathcal{L}^{-1}\!\left[(sI - Z)^{-1}\right]\Big|_{t=\Delta t}
- Then if M = sI - Z, recognize the following matrix identity:
M = \begin{bmatrix} sI - z_{11} & -z_{12} \\ 0 & sI - z_{22} \end{bmatrix}; \quad M^{-1} = \begin{bmatrix} (sI-z_{11})^{-1} & (sI-z_{11})^{-1} z_{12} (sI-z_{22})^{-1} \\ 0 & (sI-z_{22})^{-1} \end{bmatrix}.
- Then we have that:
\begin{align} c_{11} &= \mathcal{L}^{-1}\!\left[(sI-z_{11})^{-1}\right]\Big|_{t=\Delta t} = \mathcal{L}^{-1}\!\left[(sI+A)^{-1}\right]\Big|_{t=\Delta t} = e^{-A\Delta t},\\ c_{12} &= \mathcal{L}^{-1}\!\left[(sI-z_{11})^{-1} z_{12} (sI-z_{22})^{-1}\right]\Big|_{t=\Delta t} \\ &= \mathcal{L}^{-1}\!\left[(sI+A)^{-1} B_w S_w B_w^T (sI-A^T)^{-1}\right]\Big|_{t=\Delta t},\\ c_{22} &= \mathcal{L}^{-1}\!\left[(sI-z_{22})^{-1}\right]\Big|_{t=\Delta t} = \mathcal{L}^{-1}\!\left[(sI-A^T)^{-1}\right]\Big|_{t=\Delta t} = e^{A^T \Delta t}= A_d^T. \end{align}
138.3 The usefulness of C
- So, c_{22}^T = A_d. Also, we will prove that c_{22}^T c_{12} = \Sigma_{\bar{w}}
- To show this, first recognize that the transfer function of a state-space model of a system (a,b,c) with d=0 is equal to H(s) = c(sI-a)^{-1}b.
- So (sI+A)^{-1} B_w S_w B_w^T (sI-A^T)^{-1} represents the cascade of two systems:
- one with c=I, a=-A, b=B_w;
- the other with c=S_w B_w^T, \quad a=A^T, \quad b=I.
- So (sI+A)^{-1} B_w S_w B_w^T (sI-A^T)^{-1} represents the cascade of two systems:
- The term c_{12} is the inverse Laplace transform of this cascade, which is the same as the impulse response of the cascade.
- The impulse response of the cascade is the convolution of the impulse responses of the two individual systems comprising the cascade.
- Note that the impulse response of a state-space model with d=0 is c e^{at} b.
- So, the two systems have impulse responses I e^{-At} B_w \text{ and } S_w B_w^T e^{A^T t}.
138.4 Computing \Sigma_{\bar{w}}
The impulse response of the whole is the convolution of the two cascaded impulse responses: \int_{0}^{\Delta t} I e^{-A\tau} B_w S_w B_w^T e^{A^T(\Delta t-\tau)} \, d\tau .
Multiplying this result on the left by c_{22}^T = A_d = e^{A\Delta t},
c_{22}^T c_{12} = \int_{0}^{\Delta t} e^{A(\Delta t-\tau)} B_w S_w B_w^T e^{A^T(\Delta t-\tau)} \, d\tau = \Sigma_{\bar{w}}.
- In conclusion, with one
expm(.)command, we can quickly convert dynamics from continuous-time to discrete-time:
\boxed{ A_d = c_{22}^T \qquad \text{and} \qquad \Sigma_{\bar{w}} = c_{22}^T c_{12}}
138.5 A worked example (1)
- Let
\dot{x}(t) = \underbrace{\begin{bmatrix}0 & 1 \\ -1 & -1\end{bmatrix}}_{A} x(t) + \underbrace{\begin{bmatrix} 0 \\ 1 \end{bmatrix}}_{B_w} w(t)
with S_w = 0.06 \qquad \text{and} \qquad \Delta t = \frac{2\pi}{16}
Then, B_w S_w B_w^T = \begin{bmatrix}0 & 0 \\0 & 0.06 \end{bmatrix} and:
Z = \begin{bmatrix} 0 & -1 & 0 & 0 \\ 1 & 1 & 0 & 0.06 \\ 0 & 0 & 0 & -1 \\ 0 & 0 & 1 & -1 \end{bmatrix} \qquad C = \begin{bmatrix} 0.91 & -0.47 & -0.006 & -0.0046 \\ 0.47 & 1.38 & 0.0046 & 0.023 \\ 0 & 0 & 0.93 & -0.32 \\ 0 & 0 & 0.32 & 0.62 \end{bmatrix}.
138.6 A worked example (2)
From c_{12} and c_{22}, we can compute the following quantities very quickly:
A_d = \begin{bmatrix} 0.93 & 0.32 \\ -0.32 & 0.62 \end{bmatrix} \quad \Sigma_{\bar{w}} = \begin{bmatrix} 0.0009 & 0.0030 \\ 0.0030 & 0.0156 \end{bmatrix} \quad B_w S_w B_w^T = \begin{bmatrix} 0 & 0 \\ 0 & 0.06 \end{bmatrix}.
Exact \Sigma_{\bar{w}} and approximate \Sigma_{\bar{w}} are very different due to large \Delta t.
Compare predictions of steady-state performance.
Continuous: A \Sigma_{\tilde{x},ss}+ \Sigma_{\tilde{x},ss} A^T+ B_w S_w B_w^T = 0, \quad \Sigma_{\tilde{x},ss} = \begin{bmatrix}0.03 & 0 \\0 & 0.03 \end{bmatrix}
Discrete: \Sigma_{\tilde{x},ss} = A_d \Sigma_{\tilde{x},ss} A_d^T + \Sigma_{\bar{w}}, \quad \Sigma_{\tilde{x},ss} = \begin{bmatrix} 0.03 & 0 \\ 0 & 0.03 \end{bmatrix}
Because we used discrete white noise scaled to be equivalent to the continuous noise, the steady-state predictions are the same.
138.7 What about converting S_v to \Sigma_{\tilde{v}}
This is probably a good time to introduce converting S_v to \bar{\Sigma}_v.
In continuous time, the sensor noise v(t) is assumed to be zero mean and have E[v(t_1) v(t_2)^T] = S_v \, \delta(t_1 - t_2) where S_v > 0.
Approach to converting to discrete time: analyze the discrete case as \Delta t \to 0:
v_k = \frac{1}{\Delta t} \int_0^{\Delta t} v(t)\, dt \qquad \text{(average value)}.
Then,
\bar{\Sigma}_v = E[v_k v_k^T] = \frac{1}{\Delta t^2} \int_0^{\Delta t}\int_0^{\Delta t} E[v(\gamma)v(\tau)^T]\, d\gamma\, d\tau = \frac{1}{\Delta t^2}\cdot \Delta t \cdot S_v = \frac{S_v}{\Delta t}.
As \Delta t \to 0, the discrete noise tends to an infinite impulse-like term having weight S_v, similar to S_v \delta(t).
138.8 Summary
- The conversion between continuous-time and discrete-time is now complete.
Discrete A_d, \Sigma_{\tilde{w}}, B_d;
\begin{align} \text{Given } \Sigma_{\tilde{x},0} &:\Sigma_{\tilde{x},k}= A_d \Sigma_{\tilde{x},k-1} A_d^T + \Sigma_{\bar{w}} \\ \text{Given } \bar{x}_0 &: \bar{x}_k = A_d \bar{x}_{k-1} + B_d u_{k-1} \end{align}
Continuous A, S_w, B_u, B_w:
\begin{align} \text{Given } \Sigma_{\tilde{x}}(0) &: \dot{\Sigma}_{\tilde{x}}(t) = A\Sigma_{\tilde{x}}(t) + \Sigma_{\tilde{x}}(t)A^T + B_w S_w B_w^T \\ \text{Given } \bar{x}(0) &: \dot{\bar{x}}(t) = A\bar{x}(t) + B_u u(t) \end{align}
- All matrices may be time varying.
- Equivalent \Sigma_{\bar{w}} for given S_w can be computed using the trick of this lesson.
- Equivalent \Sigma_{\tilde{v}} for given S_v can also be computed as \Sigma_{\tilde{v}} = \frac{S_v}{\Delta t}.