control.matlab.freqresp¶
- control.matlab.freqresp(sys, omega, squeeze=None)[source]¶
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.
- Parameters
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’].
- Returns
response – Frequency response data object representing the frequency response. This object can be assigned to a tuple using
mag, phase, omega = response
where
mag
is the magnitude (absolute value, not dB or log10) of the system frequency response,phase
is the wrapped phase in radians of the system frequency response, andomega
is the (sorted) frequencies at which the response was evaluated. If the system is SISO and squeeze is not True,magnitude
andphase
are 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. Ifsqueeze
is True then single-dimensional axes are removed.- Return type
Notes
This function is a wrapper for
StateSpace.frequency_response()
andTransferFunction.frequency_response()
.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.