From state space to transfer function and back
لم يُترجم بعد؛ يُعرض باللغة الإنجليزية
عن هذا الدرس
One cart, two descriptions. Starting from its state-space matrices A, B, C and D, take the Laplace transform and solve for the output to get the transfer function G(s) = C(sI − A)⁻¹B + D. The determinant of sI − A becomes the denominator, so the poles are the eigenvalues of A. Then go back: the controllable canonical form rebuilds the matrices from G(s), and a change of states shows that many matrix models share one transfer function.
A cart in state space
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.
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.
اقرأ الدرس خطوة بخطوة
A cart in state space
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.
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.Read the four matrices
Newton's law gives ẋ₂ = −2x₁ − 3x₂ + u. So A = [0 1; −2 −3] holds the spring and damper, B = [0; 1] says the force changes velocity, and C = [1 0] picks position as y. D = 0.
m·ẍ = u − b·ẋ − k·x → ẍ = −2x − 3ẋ + u ẋ₁ = x₂ row 1 of A: [ 0 1] ẋ₂ = −2x₁ − 3x₂ + u row 2 of A: [−2 −3] B = [0; 1] u only enters ẋ₂ C = [1 0] y = x₁, the position D = 0 no direct path from u to yIntegrators become 1/s
A transfer function lives in the Laplace domain. There, integrating a signal divides it by s, so each integrator becomes a 1/s block. With the cart starting at rest, ẋ = Ax + Bu becomes sX(s) = AX(s) + BU(s).
Laplace transform, zero initial state: ẋ(t) → s X(s) ∫ f dt → F(s) / s ẋ = A x + B u → s X = A X + B U X(s) and U(s) are the transforms of the state and the input. The Signals lessons on the Laplace transform cover why.Gather the X terms
Move AX to the left: sX − AX = BU. To factor out X, write s as sI, the identity matrix times s: (sI − A)X = BU. Multiply by the inverse: X = (sI − A)⁻¹BU.
s X − A X = B U (s I − A) X = B U I = [1 0; 0 1] X = (s I − A)⁻¹ B U Why sI and not just s? s is a number and A is a matrix; s·I is the matrix with s on the diagonal, so the subtraction makes sense. sI − A = [ s −1 ] [ 2 s+3 ]The determinant becomes the denominator
Here sI − A = [s −1; 2 s+3]. Inverting a 2×2 matrix divides by its determinant: s(s + 3) − (−1)(2) = s² + 3s + 2. That polynomial becomes the bottom of the transfer function.
for a 2×2 matrix M = [p q; r t]: M⁻¹ = [t −q; −r p] / (p·t − q·r) det(sI − A) = s·(s+3) − (−1)·2 = s² + 3s + 2 (sI − A)⁻¹ = [s+3 1; −2 s] / (s² + 3s + 2)Multiply by C and B
B = [0; 1] picks the second column of the inverse: (1, s) over s² + 3s + 2. C = [1 0] keeps the first entry. So G(s) = Y(s)/U(s) = C(sI − A)⁻¹B + D = 1/(s² + 3s + 2).
(sI − A)⁻¹ B = [1; s] / (s² + 3s + 2) C (sI − A)⁻¹ B = 1 / (s² + 3s + 2) D = 0 G(s) = Y(s)/U(s) = 1 / (s² + 3s + 2) Check with the cart itself (m = 1, b = 3, k = 2): Newton's law m x'' + b x' + k x = u gives 1/(m s² + b s + k) = 1/(s² + 3s + 2).Poles are eigenvalues
s² + 3s + 2 = (s + 1)(s + 2), so G(s) has poles at −1 and −2. Those are exactly the eigenvalues of A: det(sI − A) = 0 is the eigenvalue equation. Same numbers, two names.
poles of G(s): s² + 3s + 2 = 0 s = −1, s = −2 eigenvalues of A: det(λI − A) = 0 λ² + 3λ + 2 = 0 λ = −1, λ = −2 Both negative: the cart settles. Any model's poles sit at its A's eigenvalues (unless a pole cancels against a zero).Same response either way
Push with a steady 1 N. Stepping ẋ = Ax + Bu in 1 ms steps, and the exact step response of G(s), 0.5 − e⁻ᵗ + 0.5e⁻²ᵗ, agree to within 0.10 mm. The cart settles at 0.5 m.
# step the state-space model, u = 1 N import math x1, x2, dt = 0.0, 0.0, 0.001 for n in range(1000): # 1 s x1, x2 = x1 + dt * x2, x2 + dt * (-2 * x1 - 3 * x2 + 1) exact = 0.5 - math.exp(-1) + 0.5 * math.exp(-2) print(f"{x1:.3f} {exact:.3f}") # 0.200 0.200Back: read off the coefficients
Going back, write G(s) = (b₁s + b₀)/(s² + a₁s + a₀). The controllable canonical form puts −a₀ and −a₁ in the bottom row of A, sets B = [0; 1] and C = [b₀ b₁]. Our round trip lands where it started.
G(s) = 1 / (s² + 3s + 2) a₁ = 3, a₀ = 2, b₁ = 0, b₀ = 1 A = [ 0 1 ] = [ 0 1] [ −a₀ −a₁ ] [−2 −3] B = [0; 1] C = [b₀ b₁] = [1 0] The denominator's coefficients, sign flipped, become A's bottom row.Many models, one G(s)
Choose new states z = T⁻¹x, two mixes of position and velocity. Now A = [−1 0; 0 −2], B = [1; −1], C = [1 1]. Different matrices, same G(s), same response. G(s) never says which states you chose.
T = [ 1 1] columns: eigenvectors of A [−1 −2] z = T⁻¹x: z₁ = 2x₁ + x₂, z₂ = −x₁ − x₂ A = T⁻¹AT = [−1 0; 0 −2] (eigenvalues!) B = T⁻¹B = [1; −1] C = C·T = [1 1] G = 1/(s+1) − 1/(s+2) = 1/(s² + 3s + 2)Check it in Python
For any 2×2 model the denominator is s² − (trace of A)s + det A. Our trace is −3 and det A is 2, so both models give s² + 3s + 2. In practice python-control does the general case with ss2tf and tf2ss.
def ss2tf_2x2(A, B, C, D=0): (a, b), (c, d) = A (b1, b2), (c1, c2) = B, C den = [1, -(a + d), a * d - b * c] # det(sI - A) n1 = c1 * b1 + c2 * b2 # C adj(sI - A) B n0 = c1 * (b * b2 - d * b1) + c2 * (c * b1 - a * b2) return [D, n1 + D * den[1], n0 + D * den[2]], den print(ss2tf_2x2([[0, 1], [-2, -3]], [0, 1], [1, 0])) print(ss2tf_2x2([[-1, 0], [0, -2]], [1, -1], [1, 1])) # ([0, 0, 1], [1, 3, 2]) both times
أسئلة سريعة: 5
اختر إجابة واحدة لكل سؤال. يمكنك تغيير اختياراتك قبل التحقق منها.
01Which formula turns a state-space model (A, B, C, D) into its transfer function?
Transform ẋ = Ax + Bu with zero initial state: sX = AX + BU, so X = (sI − A)⁻¹BU. Then Y = CX + DU gives Y/U = C(sI − A)⁻¹B + D.
02Why do we write sI − A instead of s − A?
You cannot subtract a matrix from a number. Multiplying s by the identity matrix I makes a matrix of the same size as A.
03A = [0 1; −6 −5]. What is the denominator of G(s), and where are its poles?
det(sI − A) = s(s + 5) − (−1)(6) = s² + 5s + 6 = (s + 2)(s + 3). The poles are the eigenvalues of A: −2 and −3.
04In controllable canonical form, G(s) = 4/(s² + 7s + 10) gives which A, B, C?
With a₁ = 7, a₀ = 10, b₁ = 0, b₀ = 4: A = [0 1; −a₀ −a₁], B = [0; 1], C = [b₀ b₁].
05Two different sets of matrices give the same G(s). What does that tell you?
A change of states z = T⁻¹x gives new matrices T⁻¹AT, T⁻¹B, CT but the same G(s). In the lesson, the modal form diag(−1, −2) and the original A give identical step responses (to within 0.10 mm in the simulation).
المسرد
- State-space model
- ẋ = Ax + Bu, y = Cx + Du: how the state x changes with the input u, and what output y we read from it.
- Transfer function
- G(s) = Y(s)/U(s), the ratio of the Laplace transforms of output and input, assuming the system starts at rest.
- Identity matrix I
- The square matrix with 1s on the diagonal and 0s elsewhere; I·x = x. sI puts s on the diagonal.
- Determinant
- A number (here a polynomial in s) computed from a square matrix; for [p q; r t] it is p·t − q·r. The inverse divides by it.
- Characteristic polynomial
- det(sI − A). Its roots are the eigenvalues of A and become the poles of G(s), unless a pole cancels with a zero.
- Eigenvalue
- A number λ for which Av = λv for some non-zero vector v; the roots of det(λI − A) = 0.
- Controllable canonical form
- A standard way to build A, B, C from the coefficients of G(s): the denominator's coefficients, sign flipped, fill A's bottom row.
- Realization
- Any set of matrices A, B, C, D whose transfer function is a given G(s). There are many for each G(s).
الملاحظات والمصادر
- 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.
- 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).
- Poles of G(s) are always eigenvalues of A, but if a pole cancels against a zero of the numerator, that eigenvalue disappears from G(s). The lesson on controllability and observability explains when that happens.
- N. S. Nise, Control Systems Engineering, 8th ed., Wiley (ch. 3, modelling in the time domain: converting between state space and transfer functions)
- K. Ogata, Modern Control Engineering, 5th ed., Pearson (§2-4 modelling in state space; §9-2 state-space representations of transfer-function systems)
- 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: control.ss2tf
- python-control: control.tf2ss
- Wikipedia: State-space representation (transfer function, canonical forms)
اختبار يتاح بعد الخطوة الأخيرة.