如何将 pdist2 与“mahalanobis”指标一起使用?我写了这段代码:
u=[1 2 3; 4 5 6; 7 8 9];
n=[1 2 5;2 5 7;5 7 9];
covu=nancov(u);
Z=pdist2(u,u,'mahalanobis',covu);
但我得到这个错误:
??? Error using ==> pdist2 at 298
The covariance matrix for the Mahalanobis metric must be symmetric and positive definite.
Error in ==> Untitled at 5
Z=pdist2(u,u,'mahalanobis',covu);
尽管变量 'covuu' 是对称矩阵并且也是正数。这是covu:covu =
9 9 9
9 9 9
9 9 9
如何使用“mahalabobis”度量计算 pdist2?