python函数库 阶跃 信号函数 调用_使用numpy增加阶跃函数中的分辨率

我有一个数组,它包含一个delta函数(0或1)。我使用这个函数通过应用前向填充算法来生成一个步进函数数组。这个数组就是我在某个操作中需要的。在

此图显示三角形和阶梯阵列:

但是,我需要提高这个数组的分辨率来执行操作。但是,我不能直接应用numpy.INTP公司在

扭曲了原有的功能。在

因此,我的问题是,哪种方法是提高阶跃函数分辨率的有效方法?在

这是一个示例脚本:import matplotlib.pyplot as plt

import numpy as np

def forward_filling(arr):

idx=np.where(arr==0,0,np.arange(len(arr)))

idx=np.maximum.accumulate(idx)

return arr[idx]

fig, axis = plt.subplots(1, 1)

x_array = np.arange(0, 15)

y_delta = np.zeros(len(x_array))

y_delta[3], y_delta[7], y_delta[13] = 1, 2, 3

step_function = forward_filling(y_delta)

axis.plot(x_array, y_delta, label='delta function', marker='o')

axis.plot(x_array, step_function, label='step function')

x_high_resolution = np.linspace(0, 15, 30)

delta_interpolated = np.interp(x_high_resolution, x_array, y_delta)

step_interpolated = np.interp(x_high_resolution, x_array, step_function)

axis.plot(x_high_resolution, delta_interpolated, label='delta function high resolution', marker='o')

axis.plot(x_high_resolution, step_interpolated, label='step function high resolution')

axis.legend()

axis.set_xlabel('x')

axis.set_ylabel('y')

plt.show()

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值