【发布时间】:2011-07-09 07:17:39
【问题描述】:
我有一个函数可以多次执行以下循环:
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 分别是repmat() 和mean() 的精简版本,我想知道是否有办法在标记为 (*) 的行中进行分配,从而避免使用 repmat完全。
任何其他关于如何从这件事中挤出性能的想法也将受到欢迎。
【问题讨论】:
标签: matlab