簡體   English   中英

使用 python 控制包錯誤的 Nyquist 圖

[英]Wrong Nyquist plot using python control package

我正在嘗試使用 python 繪制奈奎斯特圖。 但是,我無法正確理解。

這是我正在使用的代碼:

import control
import matplotlib.pyplot as plt

#Creating a transfer function G
s = control.TransferFunction.s

K0 = 10
T = 10
G = K0 / (s**2 * (T*s + 1))

control.nyquist(G)
plt.grid(True)
plt.title('Nyquist Diagram of G(s)')
plt.xlabel('Re(s)')
plt.ylabel('Im(s)')
plt.show()

代碼輸出此圖:

奈奎斯特圖輸出圖像

但情節應該是這樣的(來自 wolfram):

Wolfram Nyquist 圖

為什么控制包中的奈奎斯特圖是錯誤的? 我怎樣才能做對?

非常感謝。

您必須通過 matplotlib 參數進行調整。 您正在使用的 nyquist 函數將 **kwars 傳遞給 matplotlib。

你可以看到

control.nyquist

是別名

# Function aliases
bode = bode_plot
nyquist = nyquist_plot

它有這個輸入:

def nyquist_plot(syslist, omega=None, Plot=True, color=None,
             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
color : string
    Used to specify the color of the plot
labelFreq : int
    Label every nth frequency on the plot
*args
    Additional arguments for :func:`matplotlib.plot` (color, linestyle, etc)
**kwargs:
    Additional keywords (passed to `matplotlib`)

Returns
-------
real : array
    real part of the frequency response array
imag : array
    imaginary part of the frequency response array
freq : array
    frequencies

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM