Converting system from continuous time to discrete time with restricted time?

1.3k Views Asked by At

I need to find a discrete system that has the exact same states and output at $t=0.1k$, with $k \in I$, as the following continuous time system:

State Space Continuous Time System

I'm mostly confused about what to put for the sampling time. I typically do it in MATLAB with the following bit of code:

A = [-1 0 1; 0 -2 -2; 0 0 -3];
B = [1;1;2];
C = [-1 1 2];
D = 0;

T = %**? <--------------------------- I don't know what to put here with the whole 0.1k < t <0.1(k+1) thing going on**

tau = 0.13;
sys = ss(A,B,C,D);
sys.InputDelay = tau;
discsys = absorbDelay(c2d(sys,T));

Essentially, it seems to me that there is no explicit sampling time given but there is some sort of mathematical abstraction where I'm supposed to draw the sampling time. Any ideas?

2

There are 2 best solutions below

1
On BEST ANSWER

You are looking for a solution to your differential equation between those two times. In general you are going to have to recompute things every time step. From the theory of ODEs, your state equation is solved thus:

$$\vec{x}((k+1)T) = \vec{x}[k+1] = e^{AT}\vec{x}(kT) + \int_{kT}^{(k+1)T}e^{A((k+1)T-\tau}d\tau + Bu(kT)$$

The key to the entire thing is that your sampling rate, T, is what governs the bounds on the integrals. Here we went from a lower bound of $kT$ to an upper bound of $(k+1)T$. So in your question you go from $k\times0.1$ to $(k+1)\times0.1$. Hence, in your casee, $T = 0.1$

1
On

The answer by Michael Stachowsky is incomplete. It is indeed correct that the time evolution of a continuous time LTI state space model

$$ \left\{ \begin{align} \dot{x}(t) &= A\,x(t) + B\,u(t), \\ y(t) &= C\,x(t), \end{align} \right. \tag{1} $$

can be expressed using a convolution integral

$$ x(t) = e^{A\,(t-t_0)}\,x(t_0) + \int_{t_0}^t e^{A\,(t-\tau)}\,B\,u(\tau)\,d\tau. \tag{2} $$

However the input $u(t)$ is also subjected to a delay of $\delta=0.13$ time units and it is also given that $u(t)$ is equal to the constant $u_k$ for $k\,T<t\leq(k+1)\,T\ \forall\,k\in\mathbb{Z}$, with $T=0.1$ time units. Using this $(2)$ can be written as

\begin{align} x_{k+1} &= e^{A\,T}\,x_k + \int_{k\,T}^{(k+1)\,T} e^{A\left((k+1)\,T-\tau\right)}\,B\,u(\tau-\delta)\,d\tau \\ &= e^{A\,T}\,x_k + \int_{k\,T}^{k\,T+\delta-T} e^{A\left((k+1)\,T-\tau\right)}\,B\,u(\tau-\delta)\,d\tau + \int_{k\,T+\delta-T}^{(k+1)\,T} e^{A\left((k+1)\,T-\tau\right)}\,B\,u(\tau-\delta)\,d\tau \\ &= e^{A\,T}\,x_k + \int_{k\,T}^{k\,T+\delta-T} e^{A\left((k+1)\,T-\tau\right)}\,d\tau\,B\,u_{k-2} + \int_{k\,T+\delta-T}^{(k+1)\,T} e^{A\left((k+1)\,T-\tau\right)}\,d\tau\,B\,u_{k-1} \\ &= \underbrace{e^{A\,T}}_{A_d}\,x_k + \underbrace{\int_{0}^{\delta-T} e^{A\left(T-\tau\right)}\,d\tau\,B}_{B_1}\,u_{k-2} + \underbrace{\int_{\delta-T}^{T} e^{A\left(T-\tau\right)}\,d\tau\,B}_{B_2}\,u_{k-1} \end{align}

with $x_k = x(k\,T)$. Here the resulting matrices $A_d$, $B_1$ and $B_2$ are constant matrices that do not change with time. It can be noted that $T<\delta<2\,T$, that is why I split the integral after $\delta-T$, since that lies in between the integration interval. In order to be able to reuse older inputs of $u_k$ they need to be added to the state space, which can be written as

\begin{align} \begin{bmatrix} x_{k+1} \\ u_{k} \\ u_{k-1} \end{bmatrix} &= \begin{bmatrix} A_d & B_2 & B_1 \\ 0 & 0 & 0 \\ 0 & I & 0 \end{bmatrix} \begin{bmatrix} x_{k} \\ u_{k-1} \\ u_{k-2} \end{bmatrix} + \begin{bmatrix} 0 \\ I \\ 0 \end{bmatrix} u_k, \\ y_k &= \begin{bmatrix} C & 0 & 0 \end{bmatrix} \begin{bmatrix} x_{k} \\ u_{k-1} \\ u_{k-2} \end{bmatrix}. \end{align}

The values for $B_1$ and $B_2$ can be found by using a zero order hold discretization trick, which states that

$$ B_d = \int_0^T e^{A\,\tau}\,d\tau\,B $$

can also be found with

$$ e^{ \begin{bmatrix} A & B \\ 0 & 0 \end{bmatrix}T} = \begin{bmatrix} A_d & B_d \\ 0 & I \end{bmatrix}. $$

The expressions for $B_1$ and $B_2$ can be rewritten to

\begin{align} B_1 &= \int_{0}^{\delta-T} e^{A\left(T-\tau\right)}\,d\tau\,B \\ &= \int_{2\,T-\delta}^{T} e^{A\,\tau}\,d\tau\,B \\ &= \int_{0}^{T} e^{A\,\tau}\,d\tau\,B - \int_{0}^{2\,T-\delta} e^{A\,\tau}\,d\tau\,B \\ B_2 &= \int_{\delta-T}^{T} e^{A\left(T-\tau\right)}\,d\tau\,B \\ &= \int_{0}^{2\,T-\delta} e^{A\,\tau}\,d\tau\,B \end{align}

Now by using the zero order hold discretization trick it can be shown that

\begin{align} \begin{bmatrix} \mathcal{A}_1 & \mathcal{B}_1 \\ 0 & I \end{bmatrix} &= e^{ \begin{bmatrix} A & B \\ 0 & 0 \end{bmatrix}T} \\ \begin{bmatrix} \mathcal{A}_2 & \mathcal{B}_2 \\ 0 & I \end{bmatrix} &= e^{ \begin{bmatrix} A & B \\ 0 & 0 \end{bmatrix}(2\,T-\delta)} \\ B_1 &= \mathcal{B}_1 - \mathcal{B}_2 \\ B_2 &= \mathcal{B}_2 \end{align}

It can be noted that the matlab command $\texttt{absorbDelay(c2d(sys,T))}$ should give the same LTI system (with maybe differing by a similarity transformation), but this answer hopefully gives you some more insights of how to actually calculate it.