I have a function that does the following loop many, many times:
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
Noting that repmat_fast_spec and meanOneIn are truncated versions of repmat() and mean() , respectively, I wonder if there is a way to do the assignment on a line labeled (*), which avoids repmat completely.
Any other thoughts on how to squeeze performance out of this thing would also be welcome.
source share