【问题标题】:How to use scipy signal for MIMO systems如何在 MIMO 系统中使用 scipy 信号
【发布时间】:2018-06-01 13:04:40
【问题描述】:

我正在寻找一种方法来模拟各种输入信号的信号输出。更准确地说,我有一个由其传递函数 H 定义的系统,该系统接受一个输入并具有一个输出。我生成了几个信号(存储在一个 numpy 数组中)。我想做的是获得系统对每个输入信号的响应,而不使用 for 循环。有没有办法继续?下面是我目前写的代码。

from __future__ import division
import numpy as np
from scipy import signal

nbr_inputs = 5
t_in = np.arange(0,10,0.2)
dim = (nbr_inputs, len(t_in))

x = np.cumsum(np.random.normal(0,2e-3, dim), axis=1)
H = signal.TransferFunction([1, 3, 3], [1, 2, 1])
t_out, y, _ = signal.lsim(H, x[0], t_in) # here, I would just like to simply write x

感谢您的帮助

【问题讨论】:

    标签: scipy signal-processing


    【解决方案1】:

    这不是 MIMO 系统,它是 SISO 系统,但您有多个输入。

    您可以创建一个 MIMO 系统并一次性应用所有输入,这些输入将逐个通道但同时进行计算。此外,您还不能将scipy.signal.lsim 用于 MIMO 系统。您可以使用其他选项,例如python-control(如果您有slycot 扩展名,否则再次没有MIMO)或harold,如果您有Python 3.6 或更高版本(免责声明:我是作者)。

    import numpy as np
    from harold import *
    import matplotlib.pyplot
    nbr_inputs = 5
    t_in = np.arange(0,10,0.2)
    dim = (nbr_inputs, len(t_in))
    
    x = np.cumsum(np.random.normal(0,2e-3, dim), axis=1)
    
    # Forming a 1x5 system, common denominator will be completed automatically
    H = Transfer([[[1, 3, 3]]*nbr_inputs], [1, 2, 1])
    

    关键字per_channel=True 将第一个输入应用于第一个通道,将第二个输入应用于第二个,依此类推。否则返回组合响应。您可以通过玩弄它来检查形状以了解我的意思。

    # Notice it is x.T below -> input shape = <num samples>, <num inputs>
    y, t = simulate_linear_system(H, x.T, t_in, per_channel=True)
    
    plt.plot(t, y)
    

    这给了

    【讨论】:

    • 感谢您的帮助。我最终选择了 python-control,因为我使用的是 python 2.7。然而,我发现我被限制为 49 个输入。有没有办法绕过这个限制?
    • @s_o_king 不知道这个限制。你可能是内存不足还是什么?
    猜你喜欢
    • 2015-06-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-09-10
    • 1970-01-01
    • 1970-01-01
    • 2020-02-16
    相关资源
    最近更新 更多