最近在学自动控制原理,发现根轨迹这一张全是绘图的,然而书上教的全是使用matlab进行计算机辅助绘图。但国内对于使用python进行这种绘图的资料基本没有,后来发现python-control包已经将matlab的rlocus封装进去,matlab能做的python也能做。使用python绘制根轨迹图主要使用的是python-control包下的matlab.rlocus函数,具体内容可以参考:https://python-control.readthedocs.io/en/0.8.0/generated/control.matlab.rlocus.html?highlight=rlocus

官网对rclous函数的介绍:

control.matlab.rlocus
control.matlab.rlocus(sys, kvect=None, xlim=None, ylim=None, plotstr='-', Plot=True, PrintGain=True, grid=False)
Root locus plot Calculate the root locus by finding the roots of 1+k*TF(s) where TF is self.num(s)/self.den(s) and each k is an element of kvect. Parameters:
sys (LTI object) – Linear input/output systems (SISO only, for now)
kvect (list or ndarray, optional) – List of gains to use in computing diagram
xlim (tuple or list, optional) – control of x-axis range, normally with tuple (see matplotlib.axes)
ylim (tuple or list, optional) – control of y-axis range
Plot (boolean, optional (default = True)) – If True, plot root locus diagram.
PrintGain (boolean (default = True)) – If True, report mouse clicks when close to the root-locus branches, calculate gain, damping and print
grid (boolean (default = False)) – If True plot s-plane grid.
Returns:
rlist (ndarray) – Computed root locations, given as a 2d array
klist (ndarray or list) – Gains used. Same as klist keyword argument if provided.

下面根据介绍来实现绘制根轨迹图的功能:

一、导入必备包(control、matplotlib)

from control import *     #导入control包,没有的可以使用pip install control命令进行安装
from matplotlib import pyplot as plt #导入matplotlib包进行绘图

二、设定计算的参数

例如:,那么输入:

sy1 = tf([1],[4,4,1,0])     #将参数按照tf命令的格式赋值给sy1,前一个[]是分子中s的参数,第二个[]是分母s的参数

三、调用rlocus函数进行绘图

rlocus(sy1)
plt.show()

根轨迹图如下

完整代码

from control import *
from matplotlib import pyplot as plt sy1 = tf([1],[4,4,1,0]) rlocus(sy1)
plt.show()

最新文章

  1. deb包的安装及dpkg命令小结
  2. 读写注册表 registrykey 创建删除
  3. 基于bootstrap + php +ajax datatable 插件的使用
  4. Javascript中的字典和散列
  5. js按钮浮动随手指方向移动而移动
  6. json格式的日期格式化
  7. XPATH基础入门资料
  8. Android Listener 监听的几种写法
  9. 最小生成树之prim
  10. PO、BO、VO、DTO、POJO、DAO的区别
  11. 通过API函数来控制SQLite数据库增删改查
  12. Android Bitmap与DrawAble与byte[]与InputStream之间的转换工具类【转】
  13. 2.8. 创建 NSManagedObject 的子类 (Core Data 应用程序实践指南)
  14. android 原生camera——设置模块修改
  15. The 4 Essentials of Video Content Marketing Success
  16. mysql 关联表修改数据
  17. IdentityServer4实战 - 必须使用HTTPS问题解析
  18. win7 / mysql-8.0.11-winx64 安装的测坑步骤
  19. abap对象的创建和调用。方法调用
  20. 分页sql写法【只用最新的】

热门文章

  1. Rdlc 参数问题
  2. 深入浅出JAVA线程池使用原理1
  3. codeforces #305 C Mike and Foam
  4. ACM总结——2017区域赛网络赛总结
  5. IDEA循环依赖报错解决方案
  6. 从路由器镜像中提取uImage头信息
  7. 02:golang基础
  8. UI自动化(八)xpath
  9. 使用docker部署ambari的若干要点
  10. Android studio新建文件出现setContentView(R.layout.activity_main);中的R标红错误解决方法