Python Control Systems Library
The Python Control Systems Library (python-control) is an open-source Python package that implements basic operations for the analysis and design of feedback control systems. It provides functionalities for linear and nonlinear input/output systems, block diagram algebra, time and frequency response, control analysis, and design. The library is actively maintained, with version 0.10.2 being the current stable release, and follows a regular release cadence with ongoing improvements and bug fixes.
Warnings
- breaking Support for the NumPy `matrix` class has been removed in version 0.10.0. All matrix operations should now use standard NumPy arrays.
- breaking The interface for plotting has changed to a `_response/_plot` calling pattern starting from version 0.10.0. Functions like `step_response` now return a `TimeResponseData` object which has a `.plot()` method, rather than directly generating a plot.
- deprecated Functions `connect`, `ss2io`, and `tf2io` have been deprecated in version 0.10.0. Use `interconnect` for system interconnections and note that `StateSpace` and `TransferFunction` classes are now subclasses of `NonlinearIOSystem` (rendering `ss2io` and `tf2io` obsolete).
- gotcha The `python-control` library requires Python 3.10 or higher, NumPy 1.23 or higher (2.x recommended), and SciPy 1.8 or higher. Using older versions may lead to compatibility issues or unexpected behavior.
- gotcha Without the optional `slycot` library installed, some advanced functionalities and more efficient algorithms will be unavailable or operate with reduced performance. This can impact state-space conversions, robust control computations, and other routines.
Install
-
pip install python-control -
pip install python-control slycot -
conda install -c conda-forge python-control slycot
Imports
- control
import control as ct
- matlab
from control.matlab import *
Quickstart
import control as ct
import numpy as np
import matplotlib.pyplot as plt
# Define a simple state-space system
A = np.array([[-0.5, -1], [1, 0]])
B = np.array([[1], [0]])
C = np.array([[0, 1]])
D = np.array([[0]])
sys = ct.ss(A, B, C, D)
# Simulate a step response
time, response = ct.step_response(sys)
# Plot the step response
plt.plot(time, response.outputs[0])
plt.xlabel('Time (s)')
plt.ylabel('Output')
plt.title('Step Response')
plt.grid()
plt.show()