# Function reference¶

The Python Control Systems Library (control) provides common functions for analyzing and designing feedback control systems.

## System creation¶

 ss(*args) Create a state space system. tf(*args) Create a transfer function system.

## Frequency domain plotting¶

 bode(syslist[, omega, dB, Hz, deg, Plot]) Bode plot for a system bode_plot(syslist[, omega, dB, Hz, deg, Plot]) Bode plot for a system nyquist(syslist[, omega, Plot, color, labelFreq]) Nyquist plot for a system nyquist_plot(syslist[, omega, Plot, color, ...]) Nyquist plot for a system gangof4(P, C[, omega]) Plot the “Gang of 4” transfer functions for a system gangof4_plot(P, C[, omega]) Plot the “Gang of 4” transfer functions for a system nichols(syslist[, omega, grid]) Nichols plot for a system nichols_plot(syslist[, omega, grid]) Nichols plot for a system

## Time domain simulation¶

 forced_response(sys[, T, U, X0, transpose]) Simulate the output of a linear system. impulse_response(sys[, T, X0, input, ...]) Impulse response of a linear system initial_response(sys[, T, X0, input, ...]) Initial condition response of a linear system step_response(sys[, T, X0, input, output, ...]) Step response of a linear system phase_plot(odefun[, X, Y, scale, X0, T, ...]) Phase plot for 2D dynamical systems

### Convention for Time Series¶

This is a convention for function arguments and return values that represent time series: sequences of values that change over time. It is used throughout the library, for example in the functions forced_response(), step_response(), impulse_response(), and initial_response().

Note

This convention is different from the convention used in the library scipy.signal. In Scipy’s convention the meaning of rows and columns is interchanged. Thus, all 2D values must be transposed when they are used with functions from scipy.signal.

Types:

• Arguments can be arrays, matrices, or nested lists.
• Return values are arrays (not matrices).

The time vector is either 1D, or 2D with shape (1, n):

```T = [[t1,     t2,     t3,     ..., tn    ]]
```

Input, state, and output all follow the same convention. Columns are different points in time, rows are different components. When there is only one row, a 1D object is accepted or returned, which adds convenience for SISO systems:

```U = [[u1(t1), u1(t2), u1(t3), ..., u1(tn)]
[u2(t1), u2(t2), u2(t3), ..., u2(tn)]
...
...
[ui(t1), ui(t2), ui(t3), ..., ui(tn)]]

Same for X, Y
```

So, U[:,2] is the system’s input at the third point in time; and U[1] or U[1,:] is the sequence of values for the system’s second input.

The initial conditions are either 1D, or 2D with shape (j, 1):

```X0 = [[x1]
[x2]
...
...
[xj]]
```

As all simulation functions return arrays, plotting is convenient:

```t, y = step(sys)
plot(t, y)
```

The output of a MIMO system can be plotted like this:

```t, y, x = lsim(sys, u, t)
plot(t, y[0], label='y_0')
plot(t, y[1], label='y_1')
```

The convention also works well with the state space form of linear systems. If D is the feedthrough matrix of a linear system, and U is its input (matrix or array), then the feedthrough part of the system’s response, can be computed like this:

```ft = D * U
```

## Block diagram algebra¶

 series(sys1, sys2) Return the series connection sys2 * sys1 for –> sys1 –> sys2 –>. parallel(sys1, sys2) Return the parallel connection sys1 + sys2. feedback(sys1[, sys2, sign]) Feedback interconnection between two I/O systems. negate(sys) Return the negative of a system.

## Control system analysis¶

 dcgain(*args) Compute the gain of the system in steady state. evalfr(sys, x) Evaluate the transfer function of an LTI system for a single complex number x. freqresp(sys, omega) Frequency response of an LTI system at multiple angular frequencies. margin(*args) Calculate gain and phase margins and associated crossover frequencies stability_margins(sysdata[, returnall, epsw]) Calculate stability margins and associated crossover frequencies. phase_crossover_frequencies(sys) Compute frequencies and gains at intersections with real axis in Nyquist plot. pole(sys) Compute system poles. zero(sys) Compute system zeros. pzmap(sys[, Plot, title]) Plot a pole/zero map for a linear system. root_locus(sys[, kvect, xlim, ylim, ...]) Calculate the root locus by finding the roots of 1+k*TF(s) where TF is self.num(s)/self.den(s) and each k is an element of kvect.

## Matrix computations¶

 care(A, B, Q[, R, S, E]) (X,L,G) = care(A,B,Q,R=None) solves the continuous-time algebraic Riccati dare(A, B, Q, R[, S, E]) (X,L,G) = dare(A,B,Q,R) solves the discrete-time algebraic Riccati lyap(A, Q[, C, E]) X = lyap(A,Q) solves the continuous-time Lyapunov equation dlyap(A, Q[, C, E]) dlyap(A,Q) solves the discrete-time Lyapunov equation ctrb(A, B) Controllabilty matrix obsv(A, C) Observability matrix gram(sys, type) Gramian (controllability or observability)

## Control system synthesis¶

 acker(A, B, poles) Pole placement using Ackermann method lqr(*args, **keywords) Linear quadratic regulator design place(A, B, p) Place closed loop eigenvalues

## Model simplification tools¶

 minreal(sys[, tol, verbose]) Eliminates uncontrollable or unobservable states in state-space models or cancelling pole-zero pairs in transfer functions. balred(sys, orders[, method]) Balanced reduced order model of sys of a given order. hsvd(sys) Calculate the Hankel singular values. modred(sys, ELIM[, method]) Model reduction of sys by eliminating the states in ELIM using a given method. era(YY, m, n, nin, nout, r) Calculate an ERA model of order r based on the impulse-response data YY. markov(Y, U, M) Calculate the first M Markov parameters [D CB CAB ...] from input U, output Y.

## Utility functions and conversions¶

 unwrap(angle[, period]) Unwrap a phase angle to give a continuous curve db2mag(db) Convert a gain in decibels (dB) to a magnitude mag2db(mag) Convert a magnitude to decibels (dB) drss([states, outputs, inputs]) Create a stable discrete random state space object. isctime(sys[, strict]) Check to see if a system is a continuous-time system isdtime(sys[, strict]) Check to see if a system is a discrete time system issys(obj) Return True if an object is a system, otherwise False pade(T[, n]) Create a linear system that approximates a delay. sample_system(sysc, Ts[, method, alpha]) Convert a continuous time system to discrete time canonical_form(xsys[, form]) Convert a system into canonical form reachable_form(xsys) Convert a system into reachable canonical form ss2tf(*args) Transform a state space system to a transfer function. ssdata(sys) Return state space data objects for a system tf2ss(*args) Transform a transfer function to a state space system. tfdata(sys) Return transfer function data objects for a system timebase(sys[, strict]) Return the timebase for an LTI system timebaseEqual(sys1, sys2) Check to see if two systems have the same timebase