首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >使用python控制包时出现错误的奈奎斯特绘图

使用python控制包时出现错误的奈奎斯特绘图
EN

Stack Overflow用户
提问于 2020-10-20 03:21:08
回答 1查看 168关注 0票数 3

我正在尝试使用python来绘制一个奈奎斯特图。然而,我不能把它做对。

这是我使用的代码:

代码语言:javascript
运行
复制
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):

为什么控制包中的Nyquist图是错误的?我怎么才能把它弄对呢?

非常感谢。

EN

回答 1

Stack Overflow用户

发布于 2020-10-20 06:04:54

您必须通过matplotlib参数来调整它。您正在使用的nyquist函数将**kwar传递给matplotlib。

你可以看到

代码语言:javascript
运行
复制
control.nyquist

是的别名

代码语言:javascript
运行
复制
# Function aliases
bode = bode_plot
nyquist = nyquist_plot

它有以下输入:

代码语言:javascript
运行
复制
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
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/64433863

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档