Home Vectorizing for loop on square matrix in matlab
 I have a big square matrix (refConnect) with approx 500000 elements. I need to perform this operation: tmp = find(referenceCluster == 67); for j=1:length(tmp) refConnect(tmp(j),tmp)=1; end  I wonder if there is a simple way to vectorise this so I can avoid the for loop which is taking forever. Thanks for any help. Cheers