control.ss

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

Create a state space system.

The function accepts either 1, 4 or 5 positional 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 2D array_like data types. For SISO systems, B and C can be given as 1D arrays and D can be given as a scalar.

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

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

Parameters
sysStateSpace or TransferFunction

A linear system.

A, B, C, Darray_like or string

System, control, output, and feed forward matrices.

dtNone, 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).

remove_useless_statesbool, optional

If True, remove states that have no effect on the input/output dynamics. If not specified, the value is read from config.defaults['statesp.remove_useless_states'] (default = False).

methodstr, optional

Set the method used for converting a transfer function to a state space system. Current methods are ‘slycot’ and ‘scipy’. If set to None (default), try ‘slycot’ first and then ‘scipy’ (SISO only).

Returns
outStateSpace

Linear input/output system.

Other Parameters
inputs, outputs, statesstr, 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.

input_prefix, output_prefix, state_prefixstring, optional

Set the prefix for input, output, and state signals. Defaults = ‘u’, ‘y’, ‘x’.

namestring, optional

System name (used for specifying signals). If unspecified, a generic name ‘sys[id]’ is generated with a unique integer id.

Raises
ValueError

If matrix sizes are not self-consistent.

See also

StateSpace, nlsys, tf, ss2tf, tf2ss, zpk

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 transfer function to a state space system:

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