我有一个函数,它执行以下循环很多次:
for cluster=1:max(bins), % bins is a list in the same format as kmeans() IDX output
select=bins==cluster; % find group of values
means(select,:)=repmat_fast_spec(meanOneIn(x(select,:)),sum(select),1);
% (*, above) for each point, write the mean of all points in x that
% share its label in bins to the equivalent row of means
delta_x(select,:)=x(select,:)-(means(select,:));
%subtract out the mean from each point
end
注意到repmat_fast_spec和meanOneIn分别是recmat()和mean()的精简版本,我想知道是否有一种方法可以在标记为(*)的行中进行赋值,从而完全避免repmat.
关于如何从这件事中挤出表现的任何其他想法也将受到欢迎.