control.freqresp

control.freqresp(sys, omega)

Frequency response of an LTI system at multiple angular frequencies.

Parameters:
  • sys (StateSpace or TransferFunction) – Linear system
  • omega (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.
Returns:

  • mag ((self.outputs, self.inputs, len(omega)) ndarray) – The magnitude (absolute value, not dB or log10) of the system frequency response.
  • phase ((self.outputs, self.inputs, len(omega)) ndarray) – The wrapped phase in radians of the system frequency response.
  • omega (ndarray or list or tuple) – The list of sorted frequencies at which the response was evaluated.

See also

evalfr(), bode()

Notes

This function is a wrapper for StateSpace.freqresp and TransferFunction.freqresp. The output omega is a sorted version of the input omega.

Examples

>>> 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]]])

Todo

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.