首页 > 其他 > 详细

matlab Time-domain analysis 渐进式或者实时获取仿真值

时间:2019-03-29 15:35:26      阅读:149      评论:0      收藏:0      [点我收藏+]

首先准备一个传递函数sys,

然后使用lsim(sys,u,t,x0)函数(通用的时序分析的函数)

u: The input u is an array having as many rows as time samples (length(t)) and as many columns as system inputs.

x0:further specifies an initial condition x0 for the system states. This syntax applies only when sys is a state-space model. x0 is a vector whose entries are the initial values of the corresponding states of sys.

迭代使用的关键是使用上一步的结果,对x0进行赋值

具体实现:使用python环境,使用 control库。

关键代码片段如下:

1    #u是前文设置的系统输入,t是时序
2 lastValue=0
3 result=[]
4 for i in range(len(t) - 1):
5     y= lsim(T1, U=u[i:i + 2], T=t[i:i + 2], X0=lastValue)
6     lastValue = y[2][1]
7     result.append(y[0][1])

注意,y是三个数组的元组形式 y=(yout, T ,xout) 。X0传递的是xout。

 

matlab Time-domain analysis 渐进式或者实时获取仿真值

原文:https://www.cnblogs.com/xunhanliu/p/10621332.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!