【发布时间】:2014-02-24 15:56:16
【问题描述】:
有没有办法让accumarray 放弃所有观察,但每组的最后一个?
我想到的是类似的东西:
lastobs=accumarray(bin,x,[],@(x){pick the observation with the max index in each group};
举个例子,假设我有以下内容:
bin=[1 2 3 3 3 4 4]; %#The bin where the observations should be put
x= [21 3 12 5 6 8 31]; %#The vector of observations
%#The output I would like is as follow
lastobs=[21 3 6 31];
我实际上只是在考虑accumarray,因为我只是用它来计算每个 bin 的观察值的平均值。所以每一个能成功的函数对我来说都很好。
【问题讨论】:
标签: matlab accumarray