CTRB
This function builds the controllability matrix for a linear state-space system with state matrix A and input matrix B.
\mathcal{C} = [B, AB, A^2 B, \dots, A^{n-1} B]
A system is controllable when this matrix has full rank, meaning every state can be reached from a suitable input over finite time. The result is commonly used as a prerequisite check before pole placement, LQR design, and related controller synthesis tasks.
Excel Usage
=CTRB(A, B)
A(list[list], required): State dynamics matrix A.B(list[list], required): Input matrix B.
Returns (list[list]): The controllability matrix.
Example 1: Controllability of a second order system
Inputs:
| A | B | |
|---|---|---|
| 0 | 1 | 0 |
| -2 | -3 | 1 |
Excel formula:
=CTRB({0,1;-2,-3}, {0;1})
Expected output:
| Result | |
|---|---|
| 0 | 1 |
| 1 | -3 |
Example 2: Single-state controllability matrix
Inputs:
| A | B |
|---|---|
| 2 | 3 |
Excel formula:
=CTRB({2}, {3})
Expected output:
3
Example 3: Two-state system with two control channels
Inputs:
| A | B | ||
|---|---|---|---|
| 1 | 0 | 1 | 0 |
| 0 | 2 | 0 | 1 |
Excel formula:
=CTRB({1,0;0,2}, {1,0;0,1})
Expected output:
| Result | |||
|---|---|---|---|
| 1 | 0 | 1 | 0 |
| 0 | 1 | 0 | 2 |
Example 4: Double integrator controllability matrix
Inputs:
| A | B | |
|---|---|---|
| 0 | 1 | 0 |
| 0 | 0 | 1 |
Excel formula:
=CTRB({0,1;0,0}, {0;1})
Expected output:
| Result | |
|---|---|
| 0 | 1 |
| 1 | 0 |
Python Code
Show Code
import control as ct
import numpy as np
def ctrb(A, B):
"""
Compute the controllability matrix.
See: https://python-control.readthedocs.io/en/latest/generated/control.ctrb.html
This example function is provided as-is without any representation of accuracy.
Args:
A (list[list]): State dynamics matrix A.
B (list[list]): Input matrix B.
Returns:
list[list]: The controllability matrix.
"""
try:
def to_np(x):
if x is None:
return None
if not isinstance(x, list):
return np.array([[float(x)]])
if x and not isinstance(x[0], list):
x = [x]
return np.array([[float(v) if v is not None and str(v) != "" else 0.0 for v in row] for row in x])
a_np = to_np(A)
b_np = to_np(B)
C = ct.ctrb(a_np, b_np)
return C.tolist()
except Exception as e:
return f"Error: {str(e)}"Online Calculator
State dynamics matrix A.
Input matrix B.