Skip to content
Tutorials Center
My learning

Topics

Lesson 27 of 37 · State Space

State-Space Models

Learn state-space models of dynamic systems: build A, B, C, D matrices, convert to and from transfer functions, simulate with the matrix exponential, and use eigenvalues as poles.

Transfer functions describe how one input maps to one output. That is enough for a single loop, but it hides what is happening inside the system, and it becomes awkward for systems with several inputs and outputs (aircraft, robots, power grids). State-space models describe a system as a set of first-order differential equations on a vector of internal variables, the state. Almost all modern control (optimal control, observers, digital implementations) is built on this form.

A linear time-invariant (LTI) state-space model has four matrices:

TEXT
x'(t) = A x(t) + B u(t)        (state equation)
y(t)  = C x(t) + D u(t)        (output equation)
  • x is the state vector (n variables that together summarize the system's memory).
  • u is the input, y the output.
  • A (n×n) holds the internal dynamics, B (n×m) how inputs enter, C (p×n) what you measure, D (p×m) any direct feed-through (often zero).
flowchart LR
    U["u"] --> B["B"]
    B --> S(("+"))
    S --> I["integrator 1/s"]
    I -->|"x"| C["C"]
    I --> A["A"]
    A --> S
    C --> Y(("+"))
    U --> D["D"]
    D --> Y
    Y --> O["y"]

The state-space block diagram: integrators hold the state; A feeds it back on itself.

Building a model from physics

A mass m on a spring k with damper c and applied force u obeys m·x'' = u - c·x' - k·x. Choose the state as position and velocity: x1 = x, x2 = x'. Then x1' = x2 and x2' = (-k·x1 - c·x2 + u)/m. In matrices:

TEXT
A = [[0, 1], [-k/m, -c/m]]     B = [[0], [1/m]]     C = [[1, 0]]     D = [[0]]
Python From physics to A, B, C, D and a transfer function

Press Run (or Ctrl + Enter) to see the result here.

Program input · what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

The result is G(s) = 1/(s² + 2s + 5). Notice that the eigenvalues of A are the poles of the transfer function: -1 ± 2j. The state-space model tells you everything about stability and modes without a Laplace transform: the system is stable exactly when all eigenvalues of A have negative real parts.

Simulating with the matrix exponential

For a constant input u, the state equation has an exact solution. Over a step of length dt:

TEXT
x[k+1] = Ad x[k] + Bd u,     Ad = e^(A dt),     Bd = ∫0^dt e^(Aτ) B dτ

Both come from one matrix exponential of an augmented matrix, expm([[A, B], [0, 0]]·dt). This is the exact "zero-order hold" discretization, which we use again in the digital control chapter.

Python Simulate the step response with expm

Press Run (or Ctrl + Enter) to see the result here.

Program input · what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

The DC gain is -C A⁻¹ B = 0.2, and the measured overshoot matches the second-order formula (20.8%). Same system, two views.

From transfer function to state space

One transfer function has infinitely many state-space realizations. The simplest is the controllable canonical form. For G(s) = (b₁s + b₀)/(s³ + a₂s² + a₁s + a₀):

TEXT
A = [[0, 1, 0], [0, 0, 1], [-a0, -a1, -a2]]     B = [[0], [0], [1]]     C = [[b0, b1, 0]]

The states are not unique: if T is any invertible matrix, x̃ = T⁻¹x gives a model (T⁻¹AT, T⁻¹B, CT, D) with identical input-output behavior and identical eigenvalues. This is a similarity transform; only quantities invariant under it (eigenvalues, transfer function) are physically meaningful, while the state coordinates are a choice.

Python Canonical form and a similarity transform

Press Run (or Ctrl + Enter) to see the result here.

Program input · what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

The poles are -1, -2, -3 in every coordinate system, and the transfer function never changes.

Why bother with state space?

Advantage Why it matters
Multi-input multi-output (MIMO) is natural B, C just get more columns/rows
Internal behavior is visible Check controllability and observability
Time-domain design tools Pole placement, LQR
Computer-friendly Matrix algebra, exact discretization, simulation
Handles initial conditions x(0) is part of the model; transfer functions assume zero

Choosing the state: use the minimum number of independent energy-storing variables (positions and velocities for mechanical systems, capacitor voltages and inductor currents for circuits, temperatures for thermal systems). The state dimension equals the order of the system.

Check your understanding

Quick check · 4 questions

of 4 answered You scored / 4 · perfect!

  1. 1. What do the eigenvalues of A represent?

    The characteristic polynomial det(sI - A) is the denominator of the transfer function, so the eigenvalues of A are its poles.
  2. 2. For m x'' + c x' + k x = u with state (x, x'), what is A?

    x1' = x2 and x2' = (-k x1 - c x2 + u)/m, giving the matrix [[0, 1], [-k/m, -c/m]].
  3. 3. Applying a similarity transform T to the state changes which of these?

    The matrices change, but eigenvalues, transfer function and stability are invariants.
  4. 4. How do you discretize exactly for a piecewise-constant input?

    The zero-order-hold solution is Ad = e^(A dt), with Bd obtained from the exponential of [[A, B], [0, 0]] dt.

Summary

  • State space: x' = Ax + Bu, y = Cx + Du; the state holds the system's memory.
  • Eigenvalues of A are the poles; stable means all have negative real part.
  • One transfer function has many realizations related by similarity transforms; the input-output behavior does not change.
  • expm gives the exact step-by-step simulation for piecewise-constant inputs.
  • State space extends naturally to MIMO systems and underlies modern control design.

Next: Controllability and Observability