scipy.signal.

tf2ss#

scipy.signal.tf2ss(num, den)[source]#

Transfer function to state-space representation.

Parameters:
num, denarray_like

Sequences representing the coefficients of the numerator and denominator polynomials, in order of descending degree. The denominator needs to be at least as long as the numerator.

Returns:
A, B, C, Dndarray

State space representation of the system, in controller canonical form.

Examples

Convert the transfer function:

\[H(s) = \frac{s^2 + 3s + 3}{s^2 + 2s + 1}\]
>>> num = [1, 3, 3]
>>> den = [1, 2, 1]

to the state-space representation:

\[ \begin{align}\begin{aligned}\begin{split}\dot{\textbf{x}}(t) = \begin{bmatrix} -2 & -1 \\ 1 & 0 \end{bmatrix} \textbf{x}(t) + \begin{bmatrix} 1 \\ 0 \end{bmatrix} \textbf{u}(t) \\\end{split}\\\textbf{y}(t) = \begin{bmatrix} 1 & 2 \end{bmatrix} \textbf{x}(t) + \begin{bmatrix} 1 \end{bmatrix} \textbf{u}(t)\end{aligned}\end{align} \]
>>> from scipy.signal import tf2ss
>>> A, B, C, D = tf2ss(num, den)
>>> A
array([[-2., -1.],
       [ 1.,  0.]])
>>> B
array([[ 1.],
       [ 0.]])
>>> C
array([[ 1.,  2.]])
>>> D
array([[ 1.]])