control.matlab.freqresp
- control.matlab.freqresp(sysdata, omega=None, omega_limits=None, omega_num=None, Hz=None, 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
sysdata (LTI system or list of LTI systems) – Linear system(s) for which frequency response is computed.
omega (float or 1D array_like, optional) – 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. If None (default), a common set of frequencies that works across all given systems is computed.
omega_limits (array_like of two values, optional) – Limits to the range of frequencies, in rad/sec. Ignored if omega is provided, and auto-generated if omitted.
omega_num (int, optional) – Number of frequency samples to plot. Defaults to config.defaults[‘freqplot.number_of_samples’].
Hz (bool, optional) – If True, when computing frequency limits automatically set limits to full decades in Hz instead of rad/s. Omega is always returned in rad/sec.
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 False,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.Returns a list of
FrequencyResponseData
objects if sys is a list of systems.- Return type
FrequencyResponseData
See also
evalfr
,bode_plot
Notes
This function is a wrapper for
StateSpace.frequency_response()
andTransferFunction.frequency_response()
.You can also use the lower-level methods
sys(s)
orsys(z)
to generate the frequency response for a single system.All frequency data should be given in rad/sec. If frequency limits are computed automatically, the Hz keyword can be used to ensure that limits are in factors of decades in Hz, so that Bode plots with Hz=True look better.
The frequency response data can be plotted by calling the
control_bode_plot()
function or using the plot method of theFrequencyResponseData
class.
Examples
>>> G = ct.ss([[-1, -2], [3, -4]], [[5], [7]], [[6, 8]], [[9]]) >>> mag, phase, omega = ct.freqresp(G, [0.1, 1., 10.])
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.