1sX = AX + BU2(sI − A)X = BU3X = (sI − A)⁻¹BU4G = C(sI − A)⁻¹B + D5G(s) = 1/(s² + 3s + 2)1G = (b₁s+b₀)/(s²+a₁s+a₀)2a₁=3, a₀=2, b₁=0, b₀=13A = [0 1; −a₀ −a₁]4B = [0; 1], C = [b₀ b₁]uB 0 1∫ ∫1/sx₁x₂C 1 0yA 0 1−2 −3G(s)?uuuu
u/k = 0.5 m012345600.10.20.30.40.5time (s)y (m)CART POSITION, 1 N STEPx-model, steppedz-model, steppedG(s), exact−3−2−10−101real partimaginary partS-PLANE○ eigenvalues of A× poles of G(s)
Lit arrow with moving dashes: a signal is flowing along itBlocks: the matrices A, B and C with their numbers, the integrators, and G(s); the card holds the algebraPanels: the step response and the s-plane, both computed from the modelPills are signals or coefficients; their names change as they cross a blockThe cart's state-space model drawn as blocks: B, the integrators that hold the state, C, and A fed back from the state. The algebra card turns it into the transfer function G(s) = C(sI − A)⁻¹B + D, and the controllable canonical form turns G(s) back into matrices. Both panels are computed from the model: the step response of the matrices and of G(s), and the eigenvalues of A on top of the poles of G(s). A transfer function assumes the system starts at rest (zero initial state). A state-space model can also start anywhere; that extra information is lost in G(s).

The model

  1. A 1 kg cart on a spring and a damper, pushed by a force u. Its state x is two numbers: position x₁ and velocity x₂. The state-space model is ẋ = Ax + Bu and y = Cx + Du.

To a transfer function

And back

What is happening

# step 1/11 · model
# about: Force u, B matrix, ẋ = Ax + Bu, Integrators: state, A matrix, C matrix, Output y

m = 1 kg, k = 2 N/m, b = 3 N·s/m

state   x = (x₁, x₂) = (position, velocity)
input   u = force (N)
output  y = position (m)

ẋ = A x + B u      how the state changes
y = C x + D u      what we measure

Each integrator turns ẋ back into x,
so the state is what the integrators hold.

The cart's numbers (1 kg, 2 N/m, 3 N·s/m) are illustrative, chosen so the poles are whole numbers. Every curve and number in the figure is computed from the model. The Python is plain Python 3 with no libraries. python-control's ss2tf(A, B, C, D) and tf2ss(num, den) do the same for any size; tf2ss may return a different, equally valid set of matrices.