scipy.signal.step如何计算时间

时间:2016-06-09 17:06:37

标签: python scipy signals

scipy.signal.step文档说明如果未指定模拟时间,则会扣除模拟时间。 如果函数收敛,这个时间如何确定?

如果不收敛怎么办?

1 个答案:

答案 0 :(得分:1)

step是开源的。目前,代码位于this的github上。 def step(system的定义目前位于https://github.com/scipy/scipy。如果您在step搜索该文件,则会找到该函数的定义。然后,您会看到_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 是要生成的时间样本数。该函数的完整代码是:

{{1}}

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