control.ss

control.ss(A, B, C, D[, dt])[source]

Create a state space system.

The function accepts either 1, 2, 4 or 5 parameters:

ss(sys)

Convert a linear system into space system form. Always creates a new system, even if sys is already a state space system.

ss(A, B, C, D)

Create a state space system from the matrices of its state and output equations:

dx/dt &= A x + B u \\
    y &= C x + D  u

ss(A, B, C, D, dt)

Create a discrete-time state space system from the matrices of its state and output equations:

x[k+1] &= A x[k] + B u[k] \\
  y[k] &= C x[k] + D u[k]

The matrices can be given as array like data types or strings. Everything that the constructor of numpy.matrix accepts is permissible here too.

ss(args, inputs=['u1', ..., 'up'], outputs=['y1', ..., 'yq'], states=['x1', ..., 'xn'])

Create a system with named input, output, and state signals.

Parameters
  • sys (StateSpace or TransferFunction) – A linear system.

  • A (array_like or string) – System, control, output, and feed forward matrices.

  • B (array_like or string) – System, control, output, and feed forward matrices.

  • C (array_like or string) – System, control, output, and feed forward matrices.

  • D (array_like or string) – System, control, output, and feed forward matrices.

  • dt (None, True or float, optional) – System timebase. 0 (default) indicates continuous time, True indicates discrete time with unspecified sampling time, positive number is discrete time with specified sampling time, None indicates unspecified timebase (either continuous or discrete time).

  • inputs (str, or list of str, optional) – List of strings that name the individual signals. If this parameter is not given or given as None, the signal names will be of the form s[i] (where s is one of u, y, or x). See InputOutputSystem for more information.

  • outputs (str, or list of str, optional) – List of strings that name the individual signals. If this parameter is not given or given as None, the signal names will be of the form s[i] (where s is one of u, y, or x). See InputOutputSystem for more information.

  • states (str, or list of str, optional) – List of strings that name the individual signals. If this parameter is not given or given as None, the signal names will be of the form s[i] (where s is one of u, y, or x). See InputOutputSystem for more information.

  • name (string, optional) – System name (used for specifying signals). If unspecified, a generic name <sys[id]> is generated with a unique integer id.

Returns

out – Linear input/output system.

Return type

StateSpace

Raises

ValueError – If matrix sizes are not self-consistent.

See also

tf, ss2tf, tf2ss

Notes

If a transfer function is passed as the sole positional argument, the system will be converted to state space form in the same way as calling tf2ss(). The method keyword can be used to select the method for conversion.

Examples

Create a Linear I/O system object from matrices.

>>> G = ct.ss([[-1, -2], [3, -4]], [[5], [7]], [[6, 8]], [[9]])

Convert a TransferFunction to a StateSpace object.

>>> sys_tf = ct.tf([2.], [1., 3])
>>> sys2 = ct.ss(sys_tf)