control.impulse_response¶
- control.impulse_response(sys, T=None, X0=0.0, input=None, output=None, T_num=None, transpose=False, return_x=False, squeeze=None)¶
Compute the impulse response for a linear system.
If the system has multiple inputs and/or multiple outputs, the impulse response is computed for each input/output pair, with all other inputs set to zero. Optionally, a single input and/or single output can be selected, in which case all other inputs are set to 0 and all other outputs are ignored.
For information on the shape of parameters T, X0 and return values T, yout, see Time series data.
- Parameters
sys (StateSpace, TransferFunction) – LTI system to simulate
T (array_like or float, optional) – Time vector, or simulation time duration if a scalar (time vector is autocomputed if not given; see
step_response()
for more detail)X0 (array_like or float, optional) –
Initial condition (default = 0)
Numbers are converted to constant arrays with the correct shape.
input (int, optional) – Only compute the impulse response for the listed input. If not specified, the impulse responses for each independent input are computed.
output (int, optional) – Only report the step response for the listed output. If not specified, all outputs are reported.
T_num (int, optional) – Number of time steps to use in simulation if T is not provided as an array (autocomputed if not given); ignored if sys is discrete-time.
transpose (bool, optional) – If True, transpose all input and output arrays (for backward compatibility with MATLAB and
scipy.signal.lsim()
). Default value is False.return_x (bool, optional) – If True, return the state vector (default = False).
squeeze (bool, optional) – By default, if a system is single-input, single-output (SISO) then the output response is returned as a 1D array (indexed by time). If squeeze=True, remove single-dimensional entries from the shape of the output even if the system is not SISO. If squeeze=False, keep the output as a 2D array (indexed by the output number and time) even if the system is SISO. The default value can be set using config.defaults[‘control.squeeze_time_response’].
- Returns
T (array) – Time values of the output
yout (array) – Response of the system. If the system is SISO and squeeze is not True, the array is 1D (indexed by time). If the system is not SISO or squeeze is False, the array is 2D (indexed by the output number and time).
xout (array, optional) – Individual response of each x variable (if return_x is True). For a SISO system (or if a single input is specified), xout is a 2D array indexed by the state index and time. For a non-SISO system, xout is a 3D array indexed by the state, the input, and time. The shape of xout is not affected by the
squeeze
keyword.
See also
Notes
This function uses the forced_response function to compute the time response. For continuous time systems, the initial condition is altered to account for the initial impulse.
Examples
>>> T, yout = impulse_response(sys, T, X0)