如何在python中模拟一个传递函数的一步 [英] How to simulate one step to a transfer function in python
问题描述
我发现了 scipy.signal.dstep
、scipy.signal.dlsim
函数可以帮助模拟传递函数的行为,例如:<代码>signal.dlsim(signal.cont2discrete(([1], [1, 1]), 0.1), u=[1, 1], t=[0.0, 0.1])允许在 [0, 0.1]
时间间隔内对 1/(s+1)
函数建模,控制信号值为 1
.但是这些函数不允许仅使用初始值对一步进行建模.
I've found scipy.signal.dstep
, scipy.signal.dlsim
functions that help simulate behavior of a transfer function, for example:
signal.dlsim(signal.cont2discrete(([1], [1, 1]), 0.1), u=[1, 1], t=[0.0, 0.1])
allows to model 1/(s+1)
function in [0, 0.1]
time interval with control signal with value 1
.
But these functions do not allow to model just one step with initial values.
是否还有其他函数可以对传递函数的一个步骤进行建模或如何更好地进行建模?
Are there any other functions that allow to model one step of a transfer function or how it's better to do it?
推荐答案
首先,我不确定你是想用离散时间还是连续时间,因为你用的是s
运算符继续.时间,函数dstep
和dlsim
用于离散时间表示.但是,我在示例中使用了连续的.
First of all, i'm not sure, if you want to use discrete time or continuous time, because you're using s
operator for cont. time, the functions dstep
and dlsim
are used for discrete time representation. However, i used the continuous one in my example.
您可以使用scipy.signal
的lti
函数在python 中创建dlti
对象.创建的过滤器对象有一个方法 step
,其中第一个参数用于初始时间向量.lti.步骤因此,您可以使用此代码段绘制您的阶跃响应.
You can create a dlti
object in python with scipy.signal
's lti
function. The created filter object has a method step
where the first parameter is used for the initial time vector. lti.step
So you can plot your step response with this snippet.
import scipy.signal as sig
import matplotlib.pyplot as plt
filt = sig.lti(1, (1,1))
plt.plot(*filt.step())
plt.plot(*filt.step(-1))
plt.show()
如果您不想绘制它们,只需调用
If you don't want to plot them, simply call
t, a = filt.step()
这篇关于如何在python中模拟一个传递函数的一步的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!