State-space calculator
Enter A, B, C, D, or a transfer function to convert, and get the eigenvalues, the transfer function, controllable canonical form, the controllability and observability tests, a state-feedback gain by Ackermann's formula, an observer gain by duality and the closed-loop step response.
- Eigenvalues of A (open-loop poles)
- −1 ± 1.732j
- DC gain G(0)
- 1
- Transfer function
- G(s) =4s² + 2s + 4
- Stability
- Open loop stable: every eigenvalue is in the left half-plane.
Controllability
| 0 | 1 |
| 1 | −2 |
rank M_c = 2 of 2 · det M_c = −1
Controllable: every pole can be placed.
Observability
| 4 | 0 |
| 0 | 4 |
rank M_o = 2 of 2 · det M_o = 16
Observable: every observer pole can be placed.
Controllable canonical form
| 0 | 1 |
| −4 | −2 |
| 0 |
| 1 |
| 4 | 0 |
| 0 |
| 2 | 1 |
| 1 | 0 |
| 1 | 0 |
| 0 | 1 |
Same transfer function; states x̄ with x = T·x̄ and T = M_c·W when the model is controllable.
State feedback u = −Kx + N·r
Desired φ(s) = s² + 4s + 8
- K
- [4, 2]
- K̄ = K·T
- [4, 2]
- N
- 2
Eigenvalues of A − BK: −2 ± 2j
Observer x̂′ = Ax̂ + Bu + L(y − Cx̂)
Desired φ(s) = s² + 12s + 36
- Lᵀ
- [2.5, 3]
Eigenvalues of A − LC: −6 (×2)
Closed-loop step response, r = 1
- Final value
- 1
- Rise time (10–90%)
- 0.7594 s
- Peak overshoot
- 4.321%
- Settling time (2%)
- 2.108 s
Same result in code
% Controllable canonical form of G(s) = (4) / (s^2 + 2s + 4)
% (tf2ss and ss(G) choose other state coordinates)
A = [0 1; -4 -2];
B = [0; 1];
C = [4 0];
D = 0;
sys = ss(A, B, C, D);
eig(A)
G = tf(sys)
Mc = ctrb(A, B); rank(Mc), det(Mc)
Mo = obsv(A, C); rank(Mo), det(Mo)
p = [-2+2i, -2-2i];
K = acker(A, B, p) % place(A, B, p) also works for distinct poles
N = 1/(D - (C - D*K)*((A - B*K)\B))
T = ss(A - B*K, B*N, C - D*K, D*N);
step(T); stepinfo(T)
po = [-6, -6];
L = acker(A', C', po)' % observer gain by duality
eig(A - L*C)import numpy as np
import control as ct
# Controllable canonical form of G(s) = (4) / (s^2 + 2s + 4)
# (tf2ss and ss(G) choose other state coordinates)
A = np.array([[0, 1], [-4, -2]])
B = np.array([[0], [1]])
C = np.array([[4, 0]])
D = np.array([[0]])
sys = ct.ss(A, B, C, D)
print(np.linalg.eigvals(A))
print(ct.ss2tf(sys))
Mc = ct.ctrb(A, B); print(np.linalg.matrix_rank(Mc), np.linalg.det(Mc))
Mo = ct.obsv(A, C); print(np.linalg.matrix_rank(Mo), np.linalg.det(Mo))
K = ct.acker(A, B, [-2+2j, -2-2j])
N = 1 / (D - (C - D @ K) @ np.linalg.solve(A - B @ K, B))
T = ct.ss(A - B @ K, B @ N, C - D @ K, D @ N)
print(K, N, ct.step_info(T))
L = ct.acker(A.T, C.T, [-6, -6]).T
print(L, np.linalg.eigvals(A - L @ C))MATLAB uses the Control System Toolbox; Python uses python-control 0.10 or later (pip install control).
What this calculator computes
A single-input, single-output model ẋ = Ax + Bu, y = Cx + Du with up to four states. A transfer function is first written in controllable canonical form with the Lecture Room's convention: −a₀ … −aₙ₋₁ in the bottom row of A and B = [0 … 0 1]ᵀ.
The default example is the positioning drive of the state-feedback and observer lectures, and the calculator reproduces their worked examples: det M_c = −1, K = [80, 35, 11] for poles at −2 ± 2j and −10 (K̄ = [80, 46, 11] in canonical coordinates), det M_o = 1 and L = [15, 61, 64]ᵀ for three observer poles at −6.
How to read the result
- The eigenvalues of A are the open-loop poles. The transfer function is C(sI − A)⁻¹B + D; a mode that is not controllable or not observable cancels out of it, which is why both tests matter.
- Controllable means rank M_c = n with M_c = [B AB … Aⁿ⁻¹B]. When the rank is lower, the page names the modes the input cannot move (the PBH test); no state feedback can move them. Observability is the same test on [C; CA; …].
- Ackermann's formula K = [0 … 0 1]·M_c⁻¹·φ(A) puts the eigenvalues of A − BK at the chosen poles for u = −Kx + N·r, and N makes y settle at r. The observer gain L, from the same formula applied to (Aᵀ, Cᵀ), places the eigenvalues of A − LC.
Method and conventions
- The characteristic polynomial comes from the Faddeev–LeVerrier recursion, exact for integer matrices, and the numerator of G(s) from det(sI − A + BC) − det(sI − A) + D·det(sI − A), as MATLAB ss2tf computes it. Eigenvalues come from balancing and QR iteration.
- Ranks come from singular values after each column is scaled to unit length; a singular value below 10⁻¹⁰ of the largest counts as zero. Every gain is checked by recomputing the eigenvalues of A − BK and A − LC, listed beside the poles you asked for.
- The closed-loop step response is exact at every sample (a matrix exponential, not step-by-step integration), and rise time, overshoot and settling time follow the same definitions as the step-response calculator.
One input and one output, up to four states. Ackermann's formula is exact in theory but loses accuracy when M_c is nearly singular; for larger models MATLAB's place is the numerically safer choice, though it needs distinct poles. Repeated poles, such as three observer poles at −6, are fine here.