State-space models
لم يُترجم بعد؛ يُعرض باللغة الإنجليزية
عن هذا الدرس
Describe a system by its state: the few numbers it remembers. Take the cart on a spring and damper, choose position and velocity as the state, and write its motion as ẋ = Ax + Bu, y = Cx + Du. Work the matrices by hand at one moment, step them on a computer in plain Python, watch the state spiral home in the state space, and see that the eigenvalues of A are the poles of the transfer function.
What the cart remembers
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.
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
اقرأ الدرس خطوة بخطوة
What the cart remembers
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.
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 NTwo first-order equations
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.
2ẍ + 4ẋ + 50x = u (Newton, one 2nd-order eq.) ẋ₁ = x₂ ẋ₂ = (u − 4·x₂ − 50·x₁) / 2 = −25·x₁ − 2·x₂ + 0.5·u ẋ means "rate of change of x". Integrating a rate over time gives the state back: that is the ∫ block.A: how the state moves
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.
A = [[ 0, 1], row 1: ẋ₁ = 0·x₁ + 1·x₂ [-25, -2]] row 2: ẋ₂ = −25·x₁ − 2·x₂ A·x at x = [0.1, 0.5]: row 1: 0·0.1 + 1·0.5 = 0.5 row 2: −25·0.1 − 2·0.5 = −3.5 A·x = [0.5, −3.5] −25 = −k/m (spring) −2 = −b/m (damper)B: where the input enters
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.
B = [0, 0.5]ᵀ (a column: one input) B·u = [0·10, 0.5·10] = [0, 5] state equation: ẋ = A·x + B·u = [0.5, −3.5] + [0, 5] = [0.5, 1.5] One line, however many states there are.Integrate: the state moves on
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.
ẋ = [0.5, 1.5] dt = 0.001 s x_new = x + ẋ·dt = [0.1 + 0.5·0.001, 0.5 + 1.5·0.001] = [0.1005, 0.5015] A real integrator does this continuously; a computer does it in small steps.C: what we measure
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.
C = [1, 0] D = 0 y = C·x + D·u = 1·0.1 + 0·0.5 + 0·10 = 0.1 m The four matrices A, B, C, D are the whole state-space model.Step it on a computer
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.
# x' = Ax + Bu, y = Cx, forward Euler A = [[0, 1], [-25, -2]] B = [0, 0.5] x, u, dt, peak = [0.0, 0.0], 10.0, 0.001, 0.0 for n in range(6000): # 6 s dx = [A[i][0]*x[0] + A[i][1]*x[1] + B[i]*u for i in range(2)] x = [x[i] + dx[i]*dt for i in range(2)] peak = max(peak, x[0]) # y = Cx = x[0] print(round(peak, 3), round(x[0], 3)) # 0.306 0.2 # exact peak 0.305 m: Euler with 1 ms is 0.306The path through state space
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.
x₂ (velocity) against x₁ (position), same run: start (0, 0) fastest 0.76 m/s furthest 0.305 m, velocity 0 end (0.2, 0): spring force 50·0.2 = 10 N Each point is one state; the input moves it along a path that never crosses itself.Eigenvalues of A are poles
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.
sI − A = [[s, -1 ], [25, s+2 ]] det = s(s+2) + 25 = s² + 2s + 25 s = −1 ± j√24 = −1 ± j4.90 C(sI − A)⁻¹B = 0.5/(s² + 2s + 25) = 1/(2s² + 4s + 50) same cart # python-control (optional) # import control as ct # sys = ct.ss(A, B, [[1, 0]], 0); sys.poles()Why use matrices
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.
size of the matrices, n states, m inputs, p outputs: A n×n B n×m C p×n D p×m cart: n = 2, m = 1, p = 1 same form for a drone, a motor, a power grid. The transfer function only sees input → output; the state model also sees inside.
أسئلة سريعة: 5
اختر إجابة واحدة لكل سؤال. يمكنك تغيير اختياراتك قبل التحقق منها.
01Why are position and velocity enough to be the cart's state?
The state is the smallest set of numbers that, with the future input, determines everything that happens next. A second-order equation needs two starting values: position and velocity.
02For the cart 2ẍ + 4ẋ + 50x = u with x₁ = position and x₂ = velocity, what is the second row of A?
Divide by the mass: ẋ₂ = (u − 4x₂ − 50x₁)/2 = −25x₁ − 2x₂ + 0.5u. The numbers multiplying x₁ and x₂ are −25 and −2.
03At the state x = [0.1, 0.5] with u = 10 N, what is ẋ = Ax + Bu?
Ax = [0.5, −3.5] and Bu = [0, 5]; their sum is [0.5, 1.5]. The first number is the velocity, the second the acceleration.
04We measure only the position and the force has no direct path to the measurement. What are C and D?
C picks the measured state out of x, here x₁. D is the direct path from input to output, which is zero for the cart.
05The eigenvalues of A = [[0, 1], [−25, −2]] are −1 ± j4.90. What does that tell you?
det(sI − A) = s² + 2s + 25 is the denominator of the transfer function, so the eigenvalues of A are its poles. Negative real parts mean stable; the imaginary part means it oscillates.
المسرد
- State
- The smallest set of numbers that, together with the input from now on, fixes everything a system does next. For the cart: position and velocity.
- State variable
- One number in the state, such as x₁ (position) or x₂ (velocity).
- State equation
- ẋ = Ax + Bu: how fast each state changes, from the state itself (A) and the input (B).
- Output equation
- y = Cx + Du: what we measure, picked out of the state (C) plus any direct path from the input (D).
- Integrator
- A block whose output is the running total of its input over time. In a state-space diagram each state is the output of an integrator.
- State space
- The space of all possible states. For two states it is a plane, and the state traces a path through it as time runs.
- Eigenvalue
- A number λ with det(λI − A) = 0. The eigenvalues of A are the poles of the system.
الملاحظات والمصادر
- 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 state is not unique: any set of independent combinations of position and velocity would also do. Position and velocity are the natural choice here because they are what we can picture and measure.
- The Python uses forward Euler with a 1 ms step: simple, and close enough here (it peaks at 0.306 m against the exact 0.305 m). The lesson on discretising a controller compares it with better methods.
- 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.
- N. S. Nise, Control Systems Engineering, 8th ed., Wiley (ch. 3, modelling in the time domain)
- K. Ogata, Modern Control Engineering, 5th ed., Pearson (§2-4 modelling in state space; ch. 9 analysis in state space)
- G. F. Franklin, J. D. Powell, A. Emami-Naeini, Feedback Control of Dynamic Systems, 8th ed., Pearson (ch. 7 state-space design)
- MIT OpenCourseWare 16.06 Principles of Automatic Control (S. Hall)
- MIT OpenCourseWare 6.302 Feedback Systems (Roberge, Dawson, Lundberg)
- python-control documentation: control.ss (state-space systems)
اختبار يتاح بعد الخطوة الأخيرة.