我真的被困在一个有效的方法来计算欧几里德距离并确定建立稀疏矩阵的指数。我现在使用的代码是:
X = randi(10,100,5);
[m n] = size(X);
mzmax = m*(m-1) / 2; % number of non-zero distances
ij = zeros(mzmax, 2); % initialize matrix with indices
D = zeros(mzmax, n); % initialize matrix with distances
ll = 0;
for k = 1 : m-1
ll = ll(end) + (1 : m-k);
ij(ll,:) = [repmat(k, m-k, 1) (k+1 : m)']; % indices for sparse matrix
D(ll,:) = repmat(X(k,:), m-k, 1) - X(k+1:m,:); % differences between points
end
有没有办法有效识别这个D
?非常感谢提前。