Dynamical Systems:
Representations of LTI System
Table of Contents
1. Transfer Function¶
The transfer function of a system is defined as the ratio of the Laplace transforms of the output and input, assuming zero initial conditions:
$$ G(s) = \frac{Y(s)}{X(s)} $$
Equation of Motion
Consider a mass-spring-damper system governed by the second-order differential equation:
$$ m\ddot{y}(t) + c\dot{y}(t) + ky(t) = x(t) $$
Laplace Transform
Taking the Laplace transform of both sides (with zero initial conditions):
$$ (ms^2 + cs + k)Y(s) = X(s) $$
Solving for the transfer function:
$$ G(s) = \frac{Y(s)}{X(s)} = \frac{1}{ms^2 + cs + k} $$
This transfer function fully characterizes the input-output behavior of the system in the Laplace domain.
Block Diagram
Below is the block diagram representation of the system:
Example
Consider the following transfer function:
$$G(s) = \frac{s+5}{s^4+2s^3+3s^2+4s+5}$$
num = [1,5];
den = [1,2,3,4,5];
G = tf(num,den)
2. State Space Representation¶
$$ \begin{align*} \dot{x} & = Ax + Bu \\ y & = Cx + Du \end{align*} $$
MATLAB Code for State-Space Representation
A = [2.25,-5,-1.25,-0.5;
2.25,-4.25,-1.25,-0.25;
0.25,-0.5,-1.25,-1;
1.25,-1.75,-0.25,-0.75];
B = [4,6;
2,4;
2,2;
0,2];
C = [0,0,0,1;
0,2,0,2];
D = zeros(2,2);
G = ss(A,B,C,D)
G.A
$$D(s) = s^4+4s^3+6.25s^2+5.25s + 2.25$$
D = poly(G.A)
3. Three Representations of Linear Systems¶
Linear systems can be described equivalently in three domains, each offering different insights and tools for analysis:
(1) Time-Domain Representation
Convolution integral:
$$ y(t) = \int_0^t h(t - \tau) u(\tau) \, d\tau $$
- Describes how the system's impulse response $h(t)$ combines with the input $u(t)$
- Fundamental for understanding causality, memory, and transient behavior
- Applicable in both continuous and discrete time
(2) Frequency-Domain Representation
Transfer function:
$$ G(s) = \frac{Y(s)}{U(s)} = C(sI - A)^{-1}B + D $$
- Characterizes how the system filters input signals in the Laplace domain
- Facilitates algebraic manipulation and analysis of stability, resonance, and frequency response
- Converts differential equations into rational functions
(3) State-Space Representation
State equations:
$$ \dot{x} = Ax + Bu, \qquad y = Cx + Du $$
- A compact and general framework for multi-input, multi-output (MIMO) systems
- Suitable for control design, observability, and feedback implementation
- Encodes internal system dynamics using state variables
Conversions Between Representations
Each representation can be transformed into the others:
- From state-space to transfer function:
$$ G(s) = C(sI - A)^{-1}B + D $$
- From impulse response to transfer function:
$$ G(s) = \mathcal{L}\{h(t)\} $$
- From state-space to impulse response:
$$ h(t) = Ce^{At}B + D\delta(t) $$
These equivalences allow flexibility in analysis and design, depending on the nature of the system and the goals of the study.
- In linear system, convolution operation can be converted to product operation through Laplace transform.
3.1. Converting from State-Space to Transfer Function¶
A linear time-invariant (LTI) system in state-space form is given by:
$$ \begin{aligned} \dot{x}(t) &= Ax(t) + Bu(t) \\ y(t) &= Cx(t) + Du(t) \end{aligned} $$
To derive the transfer function of the system, we apply the Laplace transform (assuming zero initial conditions):
$$ \begin{aligned} sX(s) &= AX(s) + BU(s) \\ Y(s) &= CX(s) + DU(s) \end{aligned} $$
Solving the first equation for $X(s)$:
$$ (sI - A)X(s) = BU(s) \quad \Rightarrow \quad X(s) = (sI - A)^{-1}BU(s) $$
Substitute this into the output equation:
$$ \begin{aligned} Y(s) &= C(sI - A)^{-1}BU(s) + DU(s) \\ &= \left[C(sI - A)^{-1}B + D\right]U(s) \end{aligned} $$
Thus, the transfer function from input $u(t)$ to output $y(t)$ is:
$$ G(s) = \frac{Y(s)}{U(s)} = C(sI - A)^{-1}B + D $$
This expression is often referred to as the transfer function matrix in MIMO systems.
Series Expansions and the Matrix Exponential
(1) Series Expansion of $(I - C)^{-1}$
For any matrix $C$ such that the spectral radius $\rho(C) < 1$, the Neumann series converges:
$$ (I - C)^{-1} = I + C + C^2 + C^3 + \cdots $$
This expansion is analogous to the scalar geometric series:
$$ \frac{1}{1 - r} = 1 + r + r^2 + \cdots, \quad \text{for } |r| < 1 $$
(2) Series Expansion of $(sI - A)^{-1}$
To relate the transfer function matrix to the matrix exponential, consider the series expansion of $(sI - A)^{-1}$. Factoring out $\frac{1}{s}$:
$$(sI - A)^{-1} = \left(\frac{1}{s}\right) \left(I - \frac{A}{s}\right)^{-1} = \frac{I}{s} + \frac{A}{s^2} + \frac{A^2}{s^3} + \cdots = \sum_{k=0}^{\infty} \frac{A^k}{s^{k+1}}$$
This is a matrix power series in $\frac{1}{s}$, and it converges for large $|s|$ (i.e., when $\|A/s\| < 1$).
(3) Inverse Laplace Transform of the Series
Taking the inverse Laplace transform term by term:
$$\mathcal{L}^{-1} \left( \frac{I}{s} + \frac{A}{s^2} + \frac{A^2}{s^3} + \cdots \right) = I + At + \frac{(At)^2}{2!} + \cdots = e^{At} \qquad \text{or}$$
$$ \mathcal{L}^{-1}\left( \sum_{k=0}^{\infty} \frac{A^k}{s^{k+1}} \right) = \sum_{k=0}^{\infty} \frac{A^k t^k}{k!} = e^{At} $$
Thus,
$$ \mathcal{L}\{e^{At}\} = (sI - A)^{-1} $$
This result plays a central role in state-space analysis and is used to solve homogeneous linear systems.
Time-Domain Interpretation
In the time domain, the output is given by:
$$ y(t) = Ce^{At}x(0) + \int_0^t C e^{A(t - \tau)} Bu(\tau) \, d\tau + Du(t) $$
This decomposition separates the system response into:
- The homogeneous response due to initial state: $Ce^{At}x(0)$
- The forced response due to input $u(t)$: convolution with $C e^{At} B$
- The direct feedthrough (if $D \neq 0$): $Du(t)$
3.2. Transformation of State-Space Models¶
In state-space modeling, the representation of a system is not unique. That is, multiple state-space realizations can represent the same input-output behavior (i.e., the same transfer function).
This arises because the choice of the state vector is not unique—any invertible linear transformation of the state still yields a valid model of the system.
Equivalent State Representations
Suppose we are given a linear time-invariant system described by:
$$ \begin{aligned} \dot{x} &= A x + B u \\ y &= C x + D u \end{aligned} $$
Let us define a new state variable:
$$ x = T z $$
where $T \in \mathbb{R}^{n \times n}$ is an invertible matrix (i.e., a similarity transformation), and $z$ is the new state vector.
Transforming the System
Substituting $x = Tz$ into the original state equation:
$$ \begin{aligned} \dot{x} &= A x + B u = A T z + B u \\ T \dot{z} &= A T z + B u \\ \dot{z} &= T^{-1} A T z + T^{-1} B u \end{aligned} $$
The output equation becomes:
$$ y = C x + D u = C T z + D u $$
Resulting Transformed System
The transformed state-space model is:
$$ \begin{aligned} \dot{z} &= \bar{A} z + \bar{B} u \\ y &= \bar{C} z + \bar{D} u \end{aligned} $$
where:
$$ \bar{A} = T^{-1} A T, \qquad \bar{B} = T^{-1} B, \qquad \bar{C} = C T, \qquad \bar{D} = D $$
Do the Two Representations Yield the Same Transfer Function?
Yes. Let us compute the transfer functions of both representations.
Original model:
$$ G_1(s) = C(sI - A)^{-1} B + D $$
Transformed model:
$$ G_2(s) = \bar{C}(sI - \bar{A})^{-1} \bar{B} + \bar{D} $$
Now substitute the expressions for $\bar{A}, \bar{B}, \bar{C}, \bar{D}$:
$$ \begin{aligned} G_2(s) &= C T \left( sI - T^{-1} A T \right)^{-1} T^{-1} B + D \\ &= C T \left[ T^{-1}(sI - A) T \right]^{-1} T^{-1} B + D \\ &= C T T^{-1}(sI - A)^{-1} T T^{-1} B + D \\ &= C(sI - A)^{-1} B + D = G_1(s) \end{aligned} $$
A similarity transformation of the state-space model does not change the transfer function of the system:
$$ G_1(s) = G_2(s) $$
Thus, although state-space realizations are not unique, they are transfer-function equivalent under similarity transformations.
3.3. Converting a Transfer Function to State Space¶
Given a transfer function:
$$ G(s) = \frac{Y(s)}{U(s)} = \frac{b_2s^2 + b_1s + b_0}{s^3 + a_2s^2 + a_1s + a_0} $$
We aim to express this system in state-space form:
$$ \begin{aligned} \dot{x} &= Ax + Bu \\ y &= Cx + Du \end{aligned} $$
Step 1: Algebraic Rearrangement
From the transfer function:
$$ U(s) = \left(s^3 + a_2 s^2 + a_1 s + a_0 \right) X(s), \qquad Y(s) = \left(b_2 s^2 + b_1 s + b_0 \right) X(s) $$
Step 2: Inverse Laplace Transform
Take inverse Laplace transforms:
$$ \begin{aligned} u(t) &= \dddot{x}(t) + a_2 \ddot{x}(t) + a_1 \dot{x}(t) + a_0 x(t) \\ y(t) &= b_2 \ddot{x}(t) + b_1 \dot{x}(t) + b_0 x(t) \end{aligned} $$
Step 3: Choose State Variables
Define state variables based on the derivatives of $x(t)$:
$$ \begin{aligned} x_1 &= x(t) \\ x_2 &= \dot{x}(t) \\ x_3 &= \ddot{x}(t) \end{aligned} $$
Then, their time derivatives become:
$$ \begin{aligned} \dot{x}_1 &= x_2 \\ \dot{x}_2 &= x_3 \\ \dot{x}_3 &= -a_0 x_1 - a_1 x_2 - a_2 x_3 + u \end{aligned} $$
Step 4: State-Space Representation
The resulting system in matrix form:
$$ \begin{bmatrix} \dot{x}_1 \\ \dot{x}_2 \\ \dot{x}_3 \end{bmatrix} = \begin{bmatrix} 0 & 1 & 0 \\ 0 & 0 & 1 \\ -a_0 & -a_1 & -a_2 \end{bmatrix} \begin{bmatrix} x_1 \\ x_2 \\ x_3 \end{bmatrix} + \begin{bmatrix} 0 \\ 0 \\ 1 \end{bmatrix} u(t) $$
Output equation:
$$ y(t) = \begin{bmatrix} b_0 & b_1 & b_2 \end{bmatrix} \begin{bmatrix} x_1 \\ x_2 \\ x_3 \end{bmatrix} $$
This is now in the canonical controllable companion form.
Visual Representation
The corresponding block diagram shows the chain of integrators for each state and the feedback paths for coefficients $a_0, a_1, a_2$, along with output weights $b_0, b_1, b_2$. This structure provides an intuitive realization of the dynamics implied by the transfer function.
% method 1
% define a system first
num = 1;
den = [1 5];
G = tf(num,den);
[y,tout] = step(G,2);
plot(tout,y,tout,0.2*ones(size(tout)),'k--')
ylim([0,0.3])
xlabel('time')
$$ \begin{align*} \dot{x} &= -5x + u \\ y &= x \end{align*} $$
% method 2
% define a system first
A = -5;
B = 1;
C = 1;
D = 0;
G = ss(A,B,C,D);
t = linspace(0,2,100);
u = ones(size(t));
x0 = 0;
[y,tout] = lsim(G,u,t,x0);
plot(tout,y,tout,0.2*ones(size(tout)),'k--')
ylim([0,0.3])
xlabel('time')
$$
\begin{align*}
&\ddot{y} + 2\zeta\omega_n\dot{y} + \omega^2_n y = \omega^2_n u(t) \\ \\ \implies
&\;G(s) = \frac{\omega^2_n}{s^2 + 2\zeta\omega_n s + \omega^2_n }
\end{align*}
$$
z = 0.2;
wn = 1;
G = tf(wn^2,[1,2*z*wn,wn^2]);
[y,tout] = step(G,16);
plot(tout,y,tout,ones(size(tout)),'k--')
ylim([-0.1 1.6])
xlabel('time')
$$
\begin{align*}
\left[ {\begin{matrix}
\dot{x}_1 \\
\dot{x}_2 \\
\end{matrix} } \right]
&=
\left[ {\begin{matrix}
0 & 1 \\
-\omega_n^2 & -2\zeta \omega_n \\
\end{matrix} } \right]
\left[ {\begin{array}{cc}
x_1 \\
x_2 \\
\end{array} } \right] + \begin{bmatrix}0\\\omega_n^2\end{bmatrix}u \\ \\y & =
\left[ {\begin{matrix}
1 & 0
\end{matrix} } \right]
\left[ {\begin{array}{cc}
x_1 \\
x_2 \\
\end{array} } \right]
\end{align*}
$$
% method 2
% define a system first
zeta = 0.2;
wn = 1;
A = [0, 1;-wn^2, -2*zeta*wn];
B = [0; wn^2];
C = [1, 0];
D = 0;
G = ss(A,B,C,D);
t = linspace(0,16,100);
u = ones(size(t));
x0 = [0; 0];
[y,tout] = lsim(G,u,t,x0);
plot(tout,y,tout,ones(size(tout)),'k--')
ylim([-0.1 1.6])
xlabel('time')
4.2. Impulse Response¶
Now think about the impulse response
$$ \dot{y} + 5y = \delta(t), \qquad y(0) = 0 $$
The solution is given: (why?)
$$ y(t) = h(t) = e^{-5t},\quad t\geq0$$
% method 1
% define a system first
num = 1;
den = [1 5];
G = tf(num,den);
[h,tout] = impulse(G,2);
plot(tout,h), ylim([0,1])
xlabel('time')
$$ \begin{align*} \dot{x} &= -5x + u \\ y &= x \end{align*} $$
% method 2
% define a system first
A = -5;
B = 1;
C = 1;
D = 0;
G = ss(A,B,C,D);
t = linspace(0,2,100);
u = zeros(size(t));
x0 = 1;
[h,tout] = lsim(G,u,t,x0);
plot(tout,h), ylim([0,1])
xlabel('time')
$$
\begin{align*}
&\ddot{y} + 2\zeta\omega_n\dot{y} + \omega^2_n y = \omega^2_n \delta(t) \\ \\ \implies
&\;G(s) = \frac{\omega^2_n}{s^2 + 2\zeta\omega_n s + \omega^2_n }
\end{align*}
$$
z = 0.2;
wn = 1;
G = tf(wn^2,[1,2*z*wn,wn^2]);
[y,tout] = impulse(G,16);
plot(tout,y,tout,zeros(size(tout)),'k--')
ylim([-1 1])
xlabel('time')
4.3. Response to a General Input¶
Response to a general input
$$ \dot{x} + 5x = u(t), \qquad x(0) = 0 $$
The solution is given:
$$ x(t) = h(t)*u(t),\quad t\geq0$$
%plot -s 560,350
% generate a general input
[f,t] = gensig('square',4,10,0.01);
plot(t,f), axis([0,9.9,-0.1,1.1])
xlabel('t')
$$ \begin{align*} \dot{x} &= -5x + u \\ y &= x \end{align*} $$
%plot -s 560,350
% use lsim
A = -5;
B = 1;
C = 1;
D = 0;
G = ss(A,B,C,D);
x0 = 0;
[f,t] = gensig('square',4,10,0.01);
[y,tout] = lsim(G,f,t,x0);
plot(t,f), hold on
plot(tout,y), hold off, axis([0,9.9,-0.1,1.1])
xlabel('t')
z = 0.5;
wn = 1;
G = tf(wn^2,[1,2*z*wn,wn^2])
[y,tout] = step(G,12);
plot(tout,y,tout,ones(size(tout)),'--'), ylim([0 1.3])
title('Step response','fontsize',12)
xlabel('time')
wn = 1;
yy = [];
t = 0:.1:12;
zet = [0:0.2:0.9, 1+eps,2,3];
for i = 1:length(zet)
G = tf(wn^2,[1 2*zet(i)*wn,wn^2]);
[y,tout] = step(G,t);
yy = [yy; y'];
end
plot(tout,yy)
G = tf([10 20],[10 23 26 23 10])
[y,tout] = impulse(G, 30);
plot(tout,y,tout,zeros(size(tout)),'--'), ylim([-1.1 1.1])
title('Impulse response', 'fontsize', 12)
xlabel('time')
5.3. General Response using lsim¶
A = [-20 -40 -60
1 0 0
0 1 0];
B = [1 0 0]';
C = [0 0 1];
D = 0;
sys = ss(A,B,C,D); % construct a system model
t = 0:0.01:10; % simulation time = 10 seconds
u = zeros(size(t)); % no input
X0 = [0.1 0.1 0.1]; % initial conditions of the three states
[y,tout] = lsim(sys, u, t, X0); % simulate and plot the response (the output)
plot(tout,y,tout,zeros(size(tout)),'--'), ylim([-0.1 0.2])
title('Response to Non-Zero Initial Conditions and no Input','fontsize',12)
xlabel('time')
t = 0:0.01:10; % simulation time = 10 seconds
u = ones(size(t)); % u = 1, a step input
[y, tout, X] = lsim(sys,u,t); % simulate
plot(tout,y), ylim([0, 0.02])
title('Step Response with Zero Initial Conditions','fontsize',12)
xlabel('time')
LTI systems have the extremely important property that if the input to the system is sinusoidal, then the output will also be sinusoidal with the same frequency as the input, but with possibly different magnitude and phase. These magnitude and phase differences are a function of frequency and capture what is known as the frequency response of the system.
t = 0:0.01:10; % simulation time = 10 seconds
u = 10*sin(5*t+1); % input as a function of time
[y, tout, X] = lsim(sys,u,t); % simulate
plot(tout,y), ylim([-0.05,0.05])
title('Response to a Sinusoid Input with Zero Initial Conditions','fontsize',12)
xlabel('time')
6. Model Conversion¶
A = [0 1 0 0;
0 0 -1 0;
0 0 0 1;
0 0 5 0];
B = [0 1 0 -2]';
C = [1 0 0 0];
D = 0;
Gss = ss(A,B,C,D)
Gtf = tf(Gss)
[num,den] = ss2tf(A,B,C,D)
[A,B,C,D] = tf2ss(num,den)
%%javascript
$.getScript('https://kmahelona.github.io/ipython_notebook_goodies/ipython_notebook_toc.js')