首页 > 解决方案 > 如何在 scipy 中生成非周期性方波信号

问题描述

我想在 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 版本?

标签: pythonnumpyscipyconvolution

解决方案


NumPywhere可能是您正在寻找的:

def f(t):
    return np.where(np.floor(t) < 1, 1 , 0)

推荐阅读