def dimpulse(system, x0=None, t=None, n=None):
<EOL>if len(system) == <NUM_LIT:3>:<EOL><INDENT>n_inputs = <NUM_LIT:1><EOL>dt = system[<NUM_LIT:2>]<EOL><DEDENT>elif len(system) == <NUM_LIT:4>:<EOL><INDENT>n_inputs = <NUM_LIT:1><EOL>dt = system[<NUM_LIT:3>]<EOL><DEDENT>elif len(system) == <NUM_LIT:5>:<EOL><INDENT>n_inputs = system[<NUM_LIT:1>].shape[<NUM_LIT:1>]<EOL>dt = system[<NUM_LIT:4>]<EOL><DEDENT>else:<EOL><INDENT>raise ValueError("<STR_LIT>" +<EOL>"<STR_LIT>" +<EOL>"<STR_LIT>")<EOL><DEDENT>if n is None:<EOL><INDENT>n = <NUM_LIT:100><EOL><DEDENT>if t is None:<EOL><INDENT>t = np.linspace(<NUM_LIT:0>, n * dt, n, endpoint=False)<EOL><DEDENT>yout = None<EOL>for i in range(<NUM_LIT:0>, n_inputs):<EOL><INDENT>u = np.zeros((t.shape[<NUM_LIT:0>], n_inputs))<EOL>u[<NUM_LIT:0>,i] = <NUM_LIT:1.0><EOL>one_output = dlsim(system, u, t=t, x0=x0)<EOL>if yout is None:<EOL><INDENT>yout = (one_output[<NUM_LIT:1>],)<EOL><DEDENT>else:<EOL><INDENT>yout = yout + (one_output[<NUM_LIT:1>],)<EOL><DEDENT>tout = one_output[<NUM_LIT:0>]<EOL><DEDENT>return tout, yout<EOL>
Impulse response of discrete-time system.

    Parameters
    ----------
    system : tuple
        The following gives the number of elements in the tuple and
        the interpretation:

          * 3: (num, den, dt)
          * 4: (zeros, poles, gain, dt)
          * 5: (A, B, C, D, dt)

    x0 : array_like, optional
        Initial state-vector.  Defaults to zero.
    t : array_like, optional
        Time points.  Computed if not given.
    n : int, optional
        The number of time points to compute (if `t` is not given).

    Returns
    -------
    t : ndarray
        A 1-D array of time points.
    yout : tuple of array_like
        Impulse response of system.  Each element of the tuple represents
        the output of the system based on an impulse in each input.

    See Also
    --------
    impulse, dstep, dlsim, cont2discrete