matlab 如何统计时间间隔,Matlab:平均时间间隔?

您似乎尝试在输入数据集中执行步进平均值,同时保留初始输入向量的长度。据我所知,没有一个功能可以做到这一点。

但是,您可以很容易地在Python中完成它。例如:

def blurryAverage(inputCollection, step=1):

""" Perform a tiling average of an input data set according to its

step length, preserving the length of the initial input vector """

# Preconditions

if (len(inputCollection) % step != 0):

raise ValueError('Input data must be of divisible length')

ret = []

for i in range(len(inputCollection) / step):

tot = 0.0

for j in range(step):

tot += inputCollection[(i*step)+j]

for j in range(step):

ret.append(tot / step) # Implicit float coercion of step

return ret

>>> blurryAverage([1,2,3,4,5,6],3)

[2.0, 2.0, 2.0, 5.0, 5.0, 5.0]

>>> blurryAverage([1,2,3],4)

Traceback (most recent call last):

File "", line 1, in

File "", line 3, in blurryAverage

ValueError: Input data must be of divisible length

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值