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.
For continuous-time systems with transfer function G, computes the frequency response as
G(j*omega) = mag * exp(j*phase)
For discrete-time systems, the response is evaluated around the unit circle such that
G(exp(j*omega*dt)) = mag * exp(j*phase).
In general the system may be multiple input, multiple output (MIMO), where
m = self.ninputsnumber of inputs andp = self.noutputsnumber of outputs.- Parameters:
- sysdataLTI system or list of LTI systems
Linear system(s) for which frequency response is computed.
- omegafloat or 1D array_like, optional
A list, tuple, array, or scalar value of frequencies in radians/sec at which the system will be evaluated. Can be a single frequency or array of frequencies, which will be sorted before evaluation. If None (default), a common set of frequencies that works across all given systems is computed.
- omega_limitsarray_like of two values, optional
Limits to the range of frequencies, in rad/sec. Specifying
omegaas a list of two elements is equivalent to providingomega_limits. Ignored if omega is provided.- omega_numint, optional
Number of frequency samples at which to compute the response. Defaults to
config.defaults['freqplot.number_of_samples']. Ignored if omega is provided.
- Returns:
- response
FrequencyResponseData Frequency response data object representing the frequency response. When accessed as a tuple, returns
(magnitude, phase, omega). Ifsysdatais a list of systems, returns aFrequencyResponseListobject. Results can be plotted using theplotmethod. SeeFrequencyResponseDatafor more detailed information.- response.magnitudearray
Magnitude of the frequency response (absolute value, not dB or log10). 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, if omega is array_like, frequency. If
squeezeis True then single-dimensional axes are removed.- response.phasearray
Wrapped phase, in radians, with same shape as
magnitude.- response.omegaarray
Sorted list of frequencies at which response was evaluated.
- response
- Other Parameters:
- Hzbool, 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.
- squeezebool, optional
If
squeeze= True, remove single-dimensional entries from the shape of the output even if the system is not SISO. Ifsqueeze= 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 usingconfig.defaults['control.squeeze_frequency_response'].
See also
LTI.__call__,bode_plot
Notes
This function is a wrapper for
StateSpace.frequency_responseandTransferFunction.frequency_response. You can also use the lower-level methodssys(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
Hzkeyword can be used to ensure that limits are in factors of decades in Hz, so that Bode plots withHz= True look better.The frequency response data can be plotted by calling the
bode_plotfunction or using theplotmethod of theFrequencyResponseDataclass.Examples
>>> G = ct.ss([[-1, -2], [3, -4]], [[5], [7]], [[6, 8]], [[9]]) >>> mag, phase, omega = ct.frequency_response(G, [0.1, 1., 10.])
>>> sys = ct.rss(3, 2, 2) >>> mag, phase, omega = ct.frequency_response(sys, [0.1, 1., 10.]) >>> mag[0, 1, :] # Magnitude of second input to first output array([..., ..., ...]) >>> phase[1, 0, :] # Phase of first input to second output array([..., ..., ...])