>
section 7 of 128 min read

7. State-Space Methods

Transfer functions describe the input-output relationship but hide the internal state. State-space representation tracks every internal variable explicitly. It is the foundation of "modern control" since the 1960s and the dominant framework in aerospace, autonomous vehicles, and large-scale process control.

7.1 State variables

A state variable is a quantity whose value at time tt, together with the future input, fully determines the future behavior of the system. Equivalently: knowing the state lets you predict the future without needing past inputs.

For a mass-spring-damper, two state variables suffice: position xx and velocity x˙\dot x. Knowing both at any instant, plus the future force F(t)F(t), lets you integrate the differential equation forward indefinitely. Position alone is not enough; you need to know which way the mass is moving.

In general, an nn-th-order LTI system has nn state variables. A state vector x=[x1,x2,,xn]T\mathbf{x} = [x_1, x_2, \ldots, x_n]^T is the minimum information needed to predict the future.

7.2 The state-space form

The state-space form for a linear time-invariant system:

x˙(t)=Ax(t)+Bu(t)\dot{\mathbf{x}}(t) = A \mathbf{x}(t) + B \mathbf{u}(t) y(t)=Cx(t)+Du(t)\mathbf{y}(t) = C \mathbf{x}(t) + D \mathbf{u}(t)

Where:

  • x\mathbf{x}: state vector (n×1n \times 1).
  • u\mathbf{u}: input vector (r×1r \times 1).
  • y\mathbf{y}: output vector (p×1p \times 1).
  • AA (n×nn \times n): system matrix. Encodes the internal dynamics.
  • BB (n×rn \times r): input matrix. How inputs drive the state.
  • CC (p×np \times n): output matrix. How states show up in outputs.
  • DD (p×rp \times r): feedthrough matrix. Direct input-to-output coupling.

Why this form is more general than a transfer function: state-space handles MIMO (multi-input multi-output) systems, time-varying systems, and nonlinear systems (the matrices become functions of time or of state). Transfer functions only describe LTI SISO (single-input single-output) systems.

For mass-spring-damper mx¨+bx˙+kx=Fm \ddot x + b \dot x + k x = F, define x1=xx_1 = x, x2=x˙x_2 = \dot x. Then:

x˙=(01k/mb/m)x+(01/m)F\dot{\mathbf{x}} = \begin{pmatrix} 0 & 1 \\ -k/m & -b/m \end{pmatrix} \mathbf{x} + \begin{pmatrix} 0 \\ 1/m \end{pmatrix} F y=(10)xy = \begin{pmatrix} 1 & 0 \end{pmatrix} \mathbf{x}

(Output is position; first row of CC.)

7.3 Solution and the matrix exponential

For LTI systems, the state evolves according to:

x(t)=eAtx(0)+0teA(tτ)Bu(τ)dτ\mathbf{x}(t) = e^{At}\mathbf{x}(0) + \int_0^t e^{A(t-\tau)} B \mathbf{u}(\tau) \, d\tau

Where eAte^{At} is the matrix exponential (or state transition matrix). It generalizes the scalar eate^{at} to matrices and can be computed by Taylor series or by diagonalizing AA.

The eigenvalues of AA are the system poles. If all eigenvalues have negative real parts, the system is stable. This connects state-space directly to the s-plane analysis we already know.

7.4 Conversion between transfer function and state space

The transfer function from input to output in state space is:

G(s)=C(sIA)1B+DG(s) = C(sI - A)^{-1} B + D

Conversely, from a transfer function, you can build a state-space realization (canonical forms: controllable, observable, modal, Jordan). In Python:

python
from scipy.signal import tf2ss, ss2tf
 
# Transfer function: 1 / (s^2 + 2s + 1)
num = [1]
den = [1, 2, 1]
A, B, C, D = tf2ss(num, den)
print(A)  # state matrix
print(B)  # input matrix
# Going back
num2, den2 = ss2tf(A, B, C, D)

For SISO systems, transfer function and state space are equivalent. For MIMO, you need state space.

7.5 Controllability

A system is controllable if you can drive the state from any initial condition to any final condition in finite time, using only the input u(t)\mathbf{u}(t). The test:

rank(BABA2BAn1B)=n\text{rank}\begin{pmatrix} B & AB & A^2 B & \cdots & A^{n-1} B \end{pmatrix} = n

The matrix in the rank test is the controllability matrix. Full rank = controllable.

Controllability is a yes-or-no property of (A,B)(A, B). If a system is uncontrollable, some internal modes are "stuck": no matter what input you apply, you can never affect those modes. They are decoupled from your input.

Cruise-control example. If the only input is the throttle, you can affect the car's speed (controllable in speed). But you cannot affect its position on the road from side to side using throttle alone (uncontrollable in lateral position). The lateral position needs a different input (the steering wheel) to become controllable. In MIMO control, you choose inputs to make the states you care about controllable.

7.6 Observability

A system is observable if you can determine the entire state x(t)\mathbf{x}(t) from output measurements y(t)\mathbf{y}(t) alone. The test:

rank(CCACA2CAn1)=n\text{rank}\begin{pmatrix} C \\ CA \\ CA^2 \\ \vdots \\ CA^{n-1} \end{pmatrix} = n

Full rank = observable.

If the system is unobservable, some internal states are invisible to your sensors. You can never figure out their values from outputs alone.

Hardware-security tie-in. Side-channel attacks are essentially observer construction. The attacker observes power, timing, EM emissions (the "outputs" y\mathbf{y}), and tries to estimate the internal state x\mathbf{x} that contains the secret key. If the system's hidden states are observable (poorly designed crypto hardware leaks too much), the attack succeeds. If the implementation is unobservable for the secret state (constant-time, masked, with electromagnetic shielding), the attack fails. Designing for observability is good engineering; designing for unobservability of secrets is good hardware-security engineering.

7.7 Pole placement via state feedback

If the system (A,B)(A, B) is controllable, we can choose a state-feedback gain matrix KK such that the closed-loop matrix ABKA - BK has any desired eigenvalues (pole positions). This is pole placement, the modern alternative to root-locus design.

Closed-loop dynamics with state feedback u=Kx\mathbf{u} = -K \mathbf{x} (plus a reference signal):

x˙=Ax+B(Kx)=(ABK)x\dot{\mathbf{x}} = A\mathbf{x} + B(-K\mathbf{x}) = (A - BK)\mathbf{x}

The eigenvalues of (ABK)(A - BK) are the closed-loop poles. We choose KK to place them.

In Python with the control library, pole placement is one line:

python
import numpy as np
from scipy.signal import place_poles
 
A = np.array([[0, 1], [-1, -0.2]])  # mass-spring with light damping
B = np.array([[0], [1]])
desired_poles = [-2 + 1j, -2 - 1j]  # well-damped at omega_n=sqrt(5)
result = place_poles(A, B, desired_poles)
K = result.gain_matrix
print(K)

This is the modern way servo systems, autopilots, and rocket control laws are designed. Specify desired pole locations, compute KK, done.

7.8 Observers (state estimators)

In practice, you usually cannot measure the entire state directly. The state may be 6-dimensional (position, velocity, attitude, angular rate), but you have only a 3-dimensional output (position, attitude). What to do?

Build an observer: a dynamical system that takes the input u\mathbf{u} and the output y\mathbf{y} and produces an estimate x^\hat{\mathbf{x}} of the state.

The Luenberger observer has the form:

x^˙=Ax^+Bu+L(yCx^)\dot{\hat{\mathbf{x}}} = A \hat{\mathbf{x}} + B \mathbf{u} + L (\mathbf{y} - C \hat{\mathbf{x}})

The observer simulates the plant (Ax^+BuA \hat{\mathbf{x}} + B \mathbf{u}) and corrects its estimate based on the measurement residual (yCx^\mathbf{y} - C \hat{\mathbf{x}}). The gain matrix LL is chosen so the estimation error e=xx^\mathbf{e} = \mathbf{x} - \hat{\mathbf{x}} has dynamics e˙=(ALC)e\dot{\mathbf{e}} = (A - LC) \mathbf{e} with all eigenvalues in the LHP. If the system is observable, LL can be chosen to place the observer poles anywhere we want.

Use the estimate for control: u=Kx^\mathbf{u} = -K \hat{\mathbf{x}}. By the separation principle, the closed-loop poles of the observer-based controller decompose into the poles you placed via KK and the poles you placed via LL, independently. Design them separately.

The Kalman filter is the statistically optimal observer for systems with Gaussian process and measurement noise. It is the backbone of:

  • GPS receivers (combining noisy satellite signals into a clean position estimate).
  • Inertial navigation systems (integrating accelerometers and gyros).
  • Aircraft and missile guidance.
  • Quadcopter attitude estimation (combining IMU + magnetometer + GPS).
  • Robot localization and mapping.

In every drone you have ever seen, an extended Kalman filter is fusing accelerometer, gyroscope, magnetometer, barometer, and GPS data into a single best-estimate state vector that the controller acts on. State-space methods are not academic; they are the tools that fly drones and rockets.

7.9 LQR: optimal state feedback

When you have a good state-space model and a quadratic cost function, the Linear Quadratic Regulator (LQR) gives you the optimal feedback gain in closed form. Minimize:

J=0(xTQx+uTRu)dtJ = \int_0^\infty (\mathbf{x}^T Q \mathbf{x} + \mathbf{u}^T R \mathbf{u}) \, dt

Where QQ penalizes deviation of state from zero, and RR penalizes control effort. The solution is u=Kx\mathbf{u} = -K \mathbf{x} where K=R1BTPK = R^{-1} B^T P, and PP solves the algebraic Riccati equation:

ATP+PAPBR1BTP+Q=0A^T P + P A - P B R^{-1} B^T P + Q = 0

The Riccati equation looks scary but is one line in Python:

python
from scipy.linalg import solve_continuous_are
P = solve_continuous_are(A, B, Q, R)
K = np.linalg.inv(R) @ B.T @ P

LQR is widely used in aerospace, robotics, and process control. Combined with a Kalman filter for state estimation (the "LQG" combination), it is the workhorse of optimal-control practice.

7.10 State-space everywhere

Modern aerospace control is essentially all state-space. The Saturn V rocket, the Space Shuttle, every modern fighter aircraft, every autonomous car, SpaceX's Falcon 9 booster landing controller: all use state-space methods. The reasons are MIMO support, optimal-design machinery, and clean handling of constraints.

Classical control (Bode, root locus, PID) still dominates industrial process control, motor drives, and consumer products because it is simpler and the tuning intuition is widely understood. But for any system with more than a handful of states or with critical performance demands, state-space wins.