TOOLS / STATE SPACE

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.

State model / ẋ = Ax + Bu, y = Cx + Du
Start from

Coefficients in descending powers (1 3 2) or an expression such as s(s+1)(s+2). Up to degree 4. The calculator writes it in controllable canonical form.

3 poles, separated by commas: -2±2j, -10. Complex poles in conjugate pairs.

010
001
0−2−3
0
0
1
100
0
Eigenvalues of A (open-loop poles)
−2−10
DC gain G(0)
∞
Transfer function
G(s) =1s³ + 3s² + 2s
Stability
Open loop marginally stable: eigenvalues on the imaginary axis.

Controllability

001
01−3
1−37

rank M_c = 3 of 3 · det M_c = −1

Controllable: every pole can be placed.

Observability

100
010
001

rank M_o = 3 of 3 · det M_o = 1

Observable: every observer pole can be placed.

Controllable canonical form

010
001
0−2−3
0
0
1
100
0
231
310
100
100
010
001

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³ + 14s² + 48s + 80

K
[80, 46, 11]
K̄ = K·T
[80, 46, 11]
N
80

Eigenvalues of A − BK: −10−2 ± 2j

Observer x̂′ = Ax̂ + Bu + L(y − Cx̂)

Desired φ(s) = s³ + 18s² + 108s + 216

Lᵀ
[15, 61, 3]

Eigenvalues of A − LC: −6 (×3)

Closed-loop step response, r = 1

Final value
1
Rise time (10–90%)
0.7934 s
Peak overshoot
4.102%
Settling time (2%)
2.21 s

Same result in code

MATLAB
% Controllable canonical form of G(s) = (1) / (s^3 + 3s^2 + 2s)
% (tf2ss and ss(G) choose other state coordinates)
A = [0 1 0; 0 0 1; 0 -2 -3];
B = [0; 0; 1];
C = [1 0 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, -10];
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, -6];
L = acker(A', C', po)'   % observer gain by duality
eig(A - L*C)
Python (python-control)
import numpy as np
import control as ct

# Controllable canonical form of G(s) = (1) / (s^3 + 3s^2 + 2s)
# (tf2ss and ss(G) choose other state coordinates)
A = np.array([[0, 1, 0], [0, 0, 1], [0, -2, -3]])
B = np.array([[0], [0], [1]])
C = np.array([[1, 0, 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, -10])
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, -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 IT COMPUTES

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.

READ THE RESULT

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

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.
LIMITS

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.