可以尝试Matlab自带函数:pdist Pairwise distance between pairs of objects用法: D = pdist(X) D = pdist(X,distance)可以计算马氏距离~ pdist(X,'mahalanobis')