control.input_output_response(sys, T, U=0.0, X0=0, params=None, transpose=False, return_x=False, squeeze=None, solve_ivp_kwargs=None, t_eval='T', **kwargs)[source]

Compute the output response of a system to a given input.

Simulate a dynamical system with a given input and return its output and state values.

  • sys (InputOutputSystem) – Input/output system to simulate.

  • T (array-like) – Time steps at which the input is defined; values must be evenly spaced.

  • U (array-like, list, or number, optional) – Input array giving input at each time T (default = 0). If a list is specified, each element in the list will be treated as a portion of the input and broadcast (if necessary) to match the time vector.

  • X0 (array-like, list, or number, optional) – Initial condition (default = 0). If a list is given, each element in the list will be flattened and stacked into the initial condition. If a smaller number of elements are given that the number of states in the system, the initial condition will be padded with zeros.

  • t_eval (array-list, optional) – List of times at which the time response should be computed. Defaults to T.

  • return_x (bool, optional) – If True, return the state vector when assigning to a tuple (default = False). See forced_response() for more details. If True, return the values of the state at each time (default = False).

  • squeeze (bool, optional) – If True and if the system has a single output, return the system output as a 1D array rather than a 2D array. If False, return the system output as a 2D array even if the system is SISO. Default value set by config.defaults[‘control.squeeze_time_response’].

  • solve_ivp_method (str, optional) – Set the method used by scipy.integrate.solve_ivp(). Defaults to ‘RK45’.

  • solve_ivp_kwargs (dict, optional) – Pass additional keywords to scipy.integrate.solve_ivp().


results – Time response represented as a TimeResponseData object containing the following properties:

  • time (array): Time values of the output.

  • outputs (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 output and time).

  • states (array): Time evolution of the state vector, represented as a 2D array indexed by state and time.

  • inputs (array): Input(s) to the system, indexed by input and time.

  • params (dict): Parameters values used for the simulation.

The return value of the system can also be accessed by assigning the function to a tuple of length 2 (time, output) or of length 3 (time, output, state) if return_x is True. If the input/output system signals are named, these names will be used as labels for the time response.

Return type


  • TypeError – If the system is not an input/output system.

  • ValueError – If time step does not match sampling time (for discrete time systems).


  1. If a smaller number of initial conditions are given than the number of states in the system, the initial conditions will be padded with zeros. This is often useful for interconnected control systems where the process dynamics are the first system and all other components start with zero initial condition since this can be specified as [xsys_0, 0]. A warning is issued if the initial conditions are padded and and the final listed initial state is not zero.

  2. If discontinuous inputs are given, the underlying SciPy numerical integration algorithms can sometimes produce erroneous results due to the default tolerances that are used. The ivp_method and ivp_keywords parameters can be used to tune the ODE solver and produce better results. In particular, using ‘LSODA’ as the ivp_method or setting the rtol parameter to a smaller value (e.g. using ivp_kwargs={‘rtol’: 1e-4}) can provide more accurate results.