gpt4 book ai didi

python - scipy.signal.step 如何计算时间

转载 作者:太空宇宙 更新时间:2023-11-03 16:29:26 26 4
gpt4 key购买 nike

scipy.signal.step 文档中指出,如果不指定则扣除仿真时间。如果函数收敛,这个时间如何确定?

如果不收敛怎么办?

最佳答案

scipy 是开源的。目前代码位于 github 上 https://github.com/scipy/scipystep 的定义当前位于 https://github.com/scipy/scipy/blob/master/scipy/signal/ltisys.py 。如果您在该文件中搜索 def step(system),您将找到该函数的定义。然后您将看到 step 调用私有(private)函数 _default_response_times (A, n),其中 A 是系统矩阵,n 是要生成的时间样本数。该函数的完整代码为:

def _default_response_times(A, n):
"""Compute a reasonable set of time samples for the response time.
This function is used by `impulse`, `impulse2`, `step` and `step2`
to compute the response time when the `T` argument to the function
is None.
Parameters
----------
A : array_like
The system matrix, which is square.
n : int
The number of time samples to generate.
Returns
-------
t : ndarray
The 1-D array of length `n` of time samples at which the response
is to be computed.
"""
# Create a reasonable time interval.
# TODO: This could use some more work.
# For example, what is expected when the system is unstable?
vals = linalg.eigvals(A)
r = min(abs(real(vals)))
if r == 0.0:
r = 1.0
tc = 1.0 / r
t = linspace(0.0, 7 * tc, n)
return t

您可以看到,时间间隔是使用特征值实部绝对值的最小值来选择的。将此值称为r。结束时间就是 7/r(除非 r 为 0,在这种情况下时间为 7)。

关于python - scipy.signal.step 如何计算时间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37732216/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com