Skip to content
Menu

5. State-Space Realizations: The Canonical Forms

Going from a transfer function back to an internal state-space description is far less obvious than the reverse — a single transfer function corresponds to infinitely many state-space realizations, and this chapter develops the canonical forms that organize them.

PowerPoint handouts: Dark · Light

Vehicle steering in observable canonical form

Section titled “Vehicle steering in observable canonical form”
link to download code

Taking only the position y as output turns the vehicle-steering state-space model into a single-input single-output system. After a small change of variables, that model lands exactly in the observable canonical form, with a transfer function the text derives by hand: Gy(s) = (v/b)(as+v)/s^2.

This verifies the by-hand transfer function against one computed directly from the state-space matrices via ss2tf() — both routes to G(s) agree, as they must for two realizations of the same system.

import numpy as np
import control as ct
a = 1.799 / 2 # length from rear wheels to center of mass
b = 1.799 # length of the car
v_0 = 10 # initial velocity, m/s
# Linearized state-space model of the vehicle
A = np.array([[0, v_0], [0, 0]])
B = np.array([a * v_0 / b, v_0 / b])
C = np.array([[1, 0], [0, 1]])
D = np.array([[0], [0]])
sys = ct.StateSpace(A, B, C, D)
# Choosing y as the single output
C1 = np.array([[1, 0]])
D1 = np.array([0])
sys_y = ct.StateSpace(A, B, C1, D1)
# Transfer function by hand analysis
Gy = v_0 / b * ct.TransferFunction([0, a, v_0], [1, 0, 0])
print("By analysis:", Gy)
# Transfer function computed directly from the state-space model
G_y = ct.ss2tf(sys_y.A, sys_y.B, sys_y.C, sys_y.D)
print("From ss2tf: ", G_y)

Vehicle steering in observable canonical form (mcimp/codes/ssrealization/vehicle_steer_ocf.py)

Click "Run" to execute.

A similarity transform between two realizations

Section titled “A similarity transform between two realizations”
link to download code

Two state-space realizations of the same transfer function are called similar if one can be reached from the other by a linear change of state variables, x* = T^-1 x. This builds a specific third-order realization, applies the reversing permutation T = [[0,0,1],[0,1,0],[1,0,0]] (swapping x1 and x3), and shows the transformed A*, B*, C* match the alternate observable canonical form derived by hand in the text.

import control as ct
import numpy as np
a0, a1, a2 = 80, 81, 82
b0, b1, b2 = 60, 61, 62
A = np.array([[-a2, 1, 0], [-a1, 0, 1], [-a0, 0, 0]])
B = np.array([[b2], [b1], [b0]])
C = np.array([1, 0, 0])
D = np.array([1])
G = ct.ss(A, B, C, D)
print("Original realization:")
print(G)
T = np.array([[0, 0, 1], [0, 1, 0], [1, 0, 0]])
Gt = ct.similarity_transform(G, T)
print("\nSimilar realization after x* = T^-1 x:")
print(Gt)

A similarity transform between two realizations (mcimp/codes/ssrealization/similarityTransformExample.py)

Click "Run" to execute.

Python Control Toolbox’s reachable canonical form

Section titled “Python Control Toolbox’s reachable canonical form”
link to download code

The controllable canonical form isn’t unique — different textbooks and toolboxes order the states differently. This builds a state-space realization directly from transfer-function coefficients via tf2ss(), then asks the Python Control Toolbox for its own ‘reachable’ canonical form and the similarity transform T connecting the two — concretely showing the toolbox’s variant of the controllable canonical form used elsewhere in this chapter.

import numpy as np
import control as ct
# Define transfer function coefficients
b2, b1, b0 = 2, 3, 1
a2, a1, a0 = 5, 4, 2
# Construct the state-space system
num = [b2, b1, b0]
den = [1, a2, a1, a0]
G = ct.tf2ss(num, den)
print("State-space realization from tf2ss:")
print(G)
# Realize the state-space model in (Python Control Toolbox's) reachable
# canonical form, and the similarity transform T that connects the two
sys_ccf, T = ct.canonical_form(G, form='reachable')
print("\nReachable canonical form:")
print(sys_ccf)
print("\nSimilarity transform T:")
print(T)

Python Control Toolbox's reachable canonical form (mcimp/codes/ssrealization/similarityTransformExampleAlternativeCCF.py)

Click "Run" to execute.

← All chapters