IMPULSE_RESPONSE

The impulse response measures how a linear system reacts when its input is an ideal unit impulse, represented mathematically by the Dirac delta function \delta(t).

For a transfer function G(s), the impulse response is the inverse Laplace transform of that transfer function:

g(t) = \mathcal{L}^{-1}\{G(s)\}

Because the impulse response characterizes the full time-domain dynamics of an LTI system, it is a standard tool for understanding transient behavior. This wrapper returns a 2D array whose first row is the time vector and whose second row is the response values.

Excel Usage

=IMPULSE_RESPONSE(sysdata, timepts)
  • sysdata (list[list], required): The system transfer function, provided as numerator and denominator coefficients in consecutive rows.
  • timepts (list[list], optional, default: null): Optional time vector or simulation duration. If left blank, it is auto-computed based on the system’s dynamics.

Returns (list[list]): A 2D array where the first row contains the time vector values and the second row contains the system impulse response output.

Example 1: First order impulse response

Inputs:

sysdata timepts
1 0 1
1

Excel formula:

=IMPULSE_RESPONSE({1;1,1}, {0,1})

Expected output:

Result
0 1
1 0.367879
Example 2: Lightly damped impulse

Inputs:

sysdata timepts
100 0 0.1
1

Excel formula:

=IMPULSE_RESPONSE({100;1,2,100}, {0,0.1})

Expected output:

Result
0 0.1
0 7.62758

Python Code

Show Code
import control as ct
import numpy as np

def impulse_response(sysdata, timepts=None):
    """
    Compute the impulse response for a linear system.

    See: https://python-control.readthedocs.io/en/latest/generated/control.impulse_response.html

    This example function is provided as-is without any representation of accuracy.

    Args:
        sysdata (list[list]): The system transfer function, provided as numerator and denominator coefficients in consecutive rows.
        timepts (list[list], optional): Optional time vector or simulation duration. If left blank, it is auto-computed based on the system's dynamics. Default is None.

    Returns:
        list[list]: A 2D array where the first row contains the time vector values and the second row contains the system impulse response output.
    """
    try:
      def to_row_list(values):
        arr = np.asarray(values)
        if arr.ndim == 0:
          return [float(arr)]
        return [float(value) for value in arr.reshape(-1)]

      def flatten_to_1d(x):
        if not isinstance(x, list):
          return [float(x)] if str(x) != "" else []
        flat = []
        for row in x:
          if isinstance(row, list):
            for val in row:
              if str(val) != "" and val is not None:
                flat.append(float(val))
          elif row is not None and str(row) != "":
            flat.append(float(row))
        return flat

      if not sysdata or len(sysdata) < 2:
        return "Error: sysdata must contain numerator and denominator rows"

      num = flatten_to_1d(sysdata[0])
      den = flatten_to_1d(sysdata[1])

      if not num or not den:
        return "Error: Invalid numerator or denominator arrays"

      sys = ct.tf(num, den)

      t_in = flatten_to_1d(timepts) if timepts is not None else None
      if t_in is not None and len(t_in) == 1:
        t_in = float(t_in[0])
      elif t_in and len(t_in) == 0:
        t_in = None

      resp = ct.impulse_response(sys, T=t_in)
      t_list = to_row_list(resp.time)
      y_list = to_row_list(np.squeeze(resp.outputs))
      return [t_list, y_list]
    except Exception as e:
        return f"Error: {str(e)}"

Online Calculator

The system transfer function, provided as numerator and denominator coefficients in consecutive rows.
Optional time vector or simulation duration. If left blank, it is auto-computed based on the system's dynamics.