control.freqresp(sys, omega, squeeze=None)

Frequency response of an LTI system at multiple angular frequencies.

In general the system may be multiple input, multiple output (MIMO), where m = sys.ninputs number of inputs and p = sys.noutputs number of outputs.

  • sys (StateSpace or TransferFunction) – Linear system

  • omega (float or 1D array_like) – A list of frequencies in radians/sec at which the system should be evaluated. The list can be either a python list or a numpy array and will be sorted before evaluation.

  • squeeze (bool, optional) – If squeeze=True, remove single-dimensional entries from the shape of the output even if the system is not SISO. If squeeze=False, keep all indices (output, input and, if omega is array_like, frequency) even if the system is SISO. The default value can be set using config.defaults[‘control.squeeze_frequency_response’].


  • mag (ndarray) – The magnitude (absolute value, not dB or log10) of the system frequency response. If the system is SISO and squeeze is not True, the array is 1D, indexed by frequency. If the system is not SISO or squeeze is False, the array is 3D, indexed by the output, input, and frequency. If squeeze is True then single-dimensional axes are removed.

  • phase (ndarray) – The wrapped phase in radians of the system frequency response.

  • omega (ndarray) – The list of sorted frequencies at which the response was evaluated.

See also

evalfr, bode


This function is a wrapper for StateSpace.frequency_response() and TransferFunction.frequency_response().


>>> sys = ss("1. -2; 3. -4", "5.; 7", "6. 8", "9.")
>>> mag, phase, omega = freqresp(sys, [0.1, 1., 10.])
>>> mag
array([[[ 58.8576682 ,  49.64876635,  13.40825927]]])
>>> phase
array([[[-0.05408304, -0.44563154, -0.66837155]]])


Add example with MIMO system

#>>> sys = rss(3, 2, 2) #>>> mag, phase, omega = freqresp(sys, [0.1, 1., 10.]) #>>> mag[0, 1, :] #array([ 55.43747231, 42.47766549, 1.97225895]) #>>> phase[1, 0, :] #array([-0.12611087, -1.14294316, 2.5764547 ]) #>>> # This is the magnitude of the frequency response from the 2nd #>>> # input to the 1st output, and the phase (in radians) of the #>>> # frequency response from the 1st input to the 2nd output, for #>>> # s = 0.1i, i, 10i.