← Blog

part 3 · Foundations of Control Systems

A Primer on State-Space Models

Writing a mechanical system in state-space form, and reading its stability from the eigenvalues of one matrix.

Robotics and Control2 min read

A transfer function describes how one input affects one output. A state-space model keeps track of the internal variables as well, which makes it a natural fit for systems with several inputs and outputs and for computation. This primer builds a state-space model from a familiar example and shows what its main matrix tells you.

From a differential equation to states

Mass-spring-damper systemA mass m on rollers is connected to a fixed wall by a spring of stiffness k and a damper with coefficient c. A force u pushes the mass to the right, and q is its displacement.kcmforce udisplacement q
The mass-spring-damper: stiffness k, damping coefficient c, applied force u and displacement q.

A mass mm on a spring with stiffness kk and a damper with coefficient cc, driven by a force uu, obeys

mq¨+cq˙+kq=u,m\ddot{q} + c\dot{q} + kq = u,

where qq is the displacement. This is a second-order equation. To get a first-order vector equation, choose the state variables x1=qx_1 = q and x2=q˙x_2 = \dot{q}. Then x˙1=x2\dot{x}_1 = x_2 and x˙2=(u−cx2−kx1)/m\dot{x}_2 = (u - c x_2 - k x_1)/m, which in matrix form is

x˙=[01−k/m−c/m]x+[01/m]u,y=[10]x.\dot{x} = \begin{bmatrix} 0 & 1 \\ -k/m & -c/m \end{bmatrix} x + \begin{bmatrix} 0 \\ 1/m \end{bmatrix} u, \qquad y = \begin{bmatrix} 1 & 0 \end{bmatrix} x .

The general linear time-invariant form is

x˙=Ax+Bu,y=Cx+Du.\dot{x} = Ax + Bu, \qquad y = Cx + Du.
SymbolMeaningSize for nn states, mm inputs, pp outputs
xxState vectorn×1n \times 1
uuInput vectorm×1m \times 1
yyOutput vectorp×1p \times 1
AAHow the state evolves on its ownn×nn \times n
BBHow inputs enter the staten×mn \times m
CCHow the state appears in the outputp×np \times n
DDDirect path from input to outputp×mp \times m

In the example D=0D = 0, since the force does not affect the displacement instantaneously.

Stability from the eigenvalues of A

With u=0u = 0 the solution is x(t)=eAtx(0)x(t) = e^{At}x(0). It decays to zero for every initial condition if and only if every eigenvalue of AA has a negative real part. For the example the characteristic polynomial is

det⁡(sI−A)=s2+cm s+km,\det(sI - A) = s^2 + \frac{c}{m}\,s + \frac{k}{m},

with roots

s=−c±c2−4mk2m.s = \frac{-c \pm \sqrt{c^2 - 4mk}}{2m}.

For positive mm, cc and kk both roots have negative real part, so the damped oscillator is stable. When c2<4mkc^2 < 4mk the roots form a complex pair, and the system oscillates while it decays.

import numpy as np

m, c, k = 1.0, 0.5, 4.0
A = np.array([[0.0, 1.0],
              [-k / m, -c / m]])

print(np.linalg.eigvals(A))   # approximately -0.25 + 1.984j and -0.25 - 1.984j
Eigenvalues of the example system in the complex planeThe two eigenvalues, minus 0.25 plus and minus 1.984 j, lie in the shaded left half of the complex plane, where every eigenvalue has a negative real part and the response decays.-2j-1j1j2j-1.5-1-0.50.5Re sIm s−0.25 + 1.984j−0.25 − 1.984jstable: Re s < 0
Eigenvalues of A for m = 1, c = 0.5 and k = 4. Both lie in the left half-plane, so the free response decays while it oscillates.

The real part, −c/(2m)=−0.25-c/(2m) = -0.25, sets the decay rate. The imaginary part, 4mk−c2/(2m)≈1.984\sqrt{4mk - c^2}/(2m) \approx 1.984, sets the oscillation frequency in radians per second.

Why it is worth the extra notation

The same (A,B,C,D)(A, B, C, D) form describes a single mass or a robot arm with many joints, and standard linear algebra routines operate on it directly. The limits matter too. The model above is linear, so a real spring that stiffens or a damper that saturates needs linearization around an operating point, and the conclusions then hold only near that point.

← Back to all articles

Search

Arrow keys move between results. Enter opens the first result.