有没有办法让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
因为我只是用它来计算每个箱的观察平均值。所以每一个能成功的功能对我来说都很好。