我想在scipy.signal中将以下简单方块从0转换为1函数,以便将卷积操作与其他scipy.signal一起使用
def f(t): return 1 if (np.floor(t) < 1) else 0
我怎样才能做到这一点?
抱歉混淆,假设我有以下函数定义:
return np.where(np.floor(t) < 1, 1 , 0)
我怎么能写一个scipy.signal版本呢?
NumPy的where
可能就是你想要的:
def f(t):
return np.where(np.floor(t) < 1, 1 , 0)