control.input_output_response

control.input_output_response(sys, T, U=0.0, X0=0, params={}, transpose=False, return_x=False, squeeze=None, solve_ivp_kwargs={}, **kwargs)

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.

Parameters
  • 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 or number, optional) – Input array giving input at each time T (default = 0).

  • X0 (array-like or number, optional) – Initial condition (default = 0).

  • 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 (str, optional) – Pass additional keywords to scipy.integrate.solve_ivp().

Returns

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.

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

TimeResponseData

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

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