The state
Take the 2 kg cart on a 50 N/m spring and a 4 N·s/m damper. To predict its future you need two numbers now: position x₁ and velocity x₂. That pair is the state, the cart's memory.
Swap the one second-order equation 2ẍ + 4ẋ + 50x = u for two first-order ones. Position changes at the velocity: ẋ₁ = x₂. Newton gives ẋ₂ = −25x₁ − 2x₂ + 0.5u. An integrator turns each rate into its state.
The matrices
Put the numbers that multiply the states in a grid: A = [[0, 1], [−25, −2]]. Row one gives ẋ₁, row two gives ẋ₂. At x = [0.1, 0.5], A·x = [0.5, −3.5]. A holds the spring and the damper.
The force only reaches the velocity, at 1/m = 0.5 per newton, so B is the column [0, 0.5]. With u = 10 N, B·u = [0, 5]. Add the two parts and you have the state equation: ẋ = Ax + Bu.
The sum ẋ = [0.5, 1.5] is how fast the state changes. The integrator adds ẋ·dt to the state over and over. After 1 ms the state is [0.1005, 0.5015]. The integrator is the only memory here.
We measure position only, so C = [1, 0] picks x₁ out of the state: y = 0.1 m. D = 0 because the force does not reach the output directly. y = Cx + Du is the output equation.
Run it
Start at rest and push with 10 N. Every millisecond: ẋ = Ax + Bu, then x = x + ẋ·dt, then y = Cx. The cart peaks at 0.305 m after 0.64 s and settles at 0.2 m.
Plot velocity against position and the state draws a spiral into (0.2 m, 0 m/s), where the spring holds the 10 N push. The plane of all possible states is called the state space.
Solve det(sI − A) = s² + 2s + 25 = 0: s = −1 ± j4.90. These eigenvalues of A are the poles of 1/(2s² + 4s + 50). The −1 sets how fast the swing dies; 4.90 rad/s how fast it swings.
Many inputs, many outputs and many states all fit the same four matrices. A computer steps them with one loop, and the state holds things a transfer function hides. The lessons that follow use A and B to place poles.
What is happening
# step 1/10 · state # about: x₁ position, x₂ velocity state = the smallest set of numbers that, with the input from now on, fixes everything that happens next x₁ = position (m) x₂ = velocity (m/s) frozen moment used in the next steps: x = [0.1, 0.5] u = 10 N
The cart is a model with illustrative numbers (2 kg, 4 N·s/m, 50 N/m, a 10 N push from rest). Every curve is the exact solution of ẋ = Ax + Bu; every number in the steps is computed from it. The Python is plain Python 3 with lists, no numpy. python-control's ct.ss(A, B, C, D) builds the same model if you have it installed.