如何在scipy中生成非周期性方波信号

问题描述 投票:-1回答:1

我想在scipy.signal中将以下简单方块从0转换为1函数,以便将卷积操作与其他scipy.signal一起使用

def f(t): return 1 if (np.floor(t) < 1) else 0

我怎样才能做到这一点?

Edit

抱歉混淆,假设我有以下函数定义: return np.where(np.floor(t) < 1, 1 , 0)

我怎么能写一个scipy.signal版本呢?

python numpy scipy convolution
1个回答
0
投票

NumPy的where可能就是你想要的:

def f(t):
    return np.where(np.floor(t) < 1, 1 , 0)
© www.soinside.com 2019 - 2024. All rights reserved.