Frequency Domain Plotting

Plotting routines

control.bode_plot(syslist, omega=None, dB=None, Hz=None, deg=None, Plot=True, *args, **kwargs)

Bode plot for a system

Plots a Bode plot for the system over a (optional) frequency range.

Parameters:

syslist : linsys

List of linear input/output systems (single system is OK)

omega : freq_range

Range of frequencies (list or bounds) in rad/sec

dB : boolean

If True, plot result in dB

Hz : boolean

If True, plot frequency in Hz (omega must be provided in rad/sec)

deg : boolean

If True, return phase in degrees (else radians)

Plot : boolean

If True, plot magnitude and phase

*args, **kwargs: :

Additional options to matplotlib (color, linestyle, etc)

Returns:

mag : array (list if len(syslist) > 1)

magnitude

phase : array (list if len(syslist) > 1)

phase

omega : array (list if len(syslist) > 1)

frequency

Notes

1. Alternatively, you may use the lower-level method (mag, phase, freq) = sys.freqresp(freq) to generate the frequency response for a system, but it returns a MIMO response.

2. If a discrete time model is given, the frequency response is plotted along the upper branch of the unit circle, using the mapping z = exp(j omega dt) where omega ranges from 0 to pi/dt and dt is the discrete time base. If not timebase is specified (dt = True), dt is set to 1.

Examples

>>> sys = ss("1. -2; 3. -4", "5.; 7", "6. 8", "9.")
>>> mag, phase, omega = bode(sys)
control.nyquist_plot(syslist, omega=None, Plot=True, color='b', labelFreq=0, *args, **kwargs)

Nyquist plot for a system

Plots a Nyquist plot for the system over a (optional) frequency range.

Parameters:

syslist : list of Lti

List of linear input/output systems (single system is OK)

omega : freq_range

Range of frequencies (list or bounds) in rad/sec

Plot : boolean

If True, plot magnitude

labelFreq : int

Label every nth frequency on the plot

*args, **kwargs: :

Additional options to matplotlib (color, linestyle, etc)

Returns:

real : array

real part of the frequency response array

imag : array

imaginary part of the frequency response array

freq : array

frequencies

Examples

>>> sys = ss("1. -2; 3. -4", "5.; 7", "6. 8", "9.")
>>> real, imag, freq = nyquist_plot(sys)
control.gangof4_plot(P, C, omega=None)

Plot the “Gang of 4” transfer functions for a system

Generates a 2x2 plot showing the “Gang of 4” sensitivity functions [T, PS; CS, S]

Parameters:

P, C : Lti

Linear input/output systems (process and control)

omega : array

Range of frequencies (list or bounds) in rad/sec

Returns:

None :

control.nichols_plot(syslist, omega=None, grid=True)

Nichols plot for a system

Plots a Nichols plot for the system over a (optional) frequency range.

Parameters:

syslist : list of Lti, or Lti

List of linear input/output systems (single system is OK)

omega : array_like

Range of frequencies (list or bounds) in rad/sec

grid : boolean, optional

True if the plot should include a Nichols-chart grid. Default is True.

Returns:

None :

Utility functions

control.freqplot.default_frequency_range(syslist)

Compute a reasonable default frequency range for frequency domain plots.

Finds a reasonable default frequency range by examining the features (poles and zeros) of the systems in syslist.

Parameters:

syslist : list of Lti

List of linear input/output systems (single system is OK)

Returns:

omega : array

Range of frequencies in rad/sec

Examples

>>> from matlab import ss
>>> sys = ss("1. -2; 3. -4", "5.; 7", "6. 8", "9.")
>>> omega = default_frequency_range(sys)