algorithm - Efficient way of generating "item-item distance rank matrix" in MATLAB? -
i have 1000-by-3 matrix x
containing 1000 datapoints in 3d space. can generate item-item mahalanobis distance matrix in matlab:
x = random(1000, 3); distmat = pdist(x, 'mahalanobis'); distmat = squareform(distmat);
where (i
, j
)-th entry distance between point i
, point j
.
now wish have similar matrix (i
, j
)-th entry rank of point i
among points based on distance point j
. call "item-item distance rank matrix."
my idea sort each row of distmat
, construct desired matrix sorting indices, requires 1000 sorting operations. believe there's more efficient way.
Comments
Post a Comment