matlab中pdist2(X,X)函数以及pdist2(X,Y)函数的具体使用方法 您所在的位置:网站首页 pdist函数怎么用 matlab中pdist2(X,X)函数以及pdist2(X,Y)函数的具体使用方法

matlab中pdist2(X,X)函数以及pdist2(X,Y)函数的具体使用方法

#matlab中pdist2(X,X)函数以及pdist2(X,Y)函数的具体使用方法| 来源: 网络整理| 查看: 265

1、pdist2(X,X)的使用 X=rand(3) X = 0.8052 0.6568 0.8994 0.3869 0.2429 0.9025 0.3199 0.9852 0.4783 K>> pdist2(X,X) ans = 0 0.5885 0.7216 0.5885 0 0.8576 0.7216 0.8576 0

怎么计算的呢?将X中的每一行的元素看成一个行矩阵,pdist2(X,X)函数的第一行第一列的元素为X的第一行减去第一行,然后根据欧几里得公式d_{st}=\sqrt{(X_{s}-X_{t})\cdot (X_{s}-X_{t})^{T}} 得\sqrt{[0,0,0]\cdot [0,0,0]^{t}} =0

D=X(1,1:3)-X(1,1:3) D = 0 0 0 K>> pdist2_11=(D*D')^(1/2) pdist2_11 = 0

pdist2(X,X)函数的第一行第二列的元素为X的第一行减去第二行,然后根据欧几里得公式d_{st}=\sqrt{(X_{s}-X_{t})\cdot (X_{s}-X_{t})^{T}} 得如下

D=X(1,1:3)-X(2,1:3) D = 0.4183 0.4139 -0.0031 pdist2_12=(D*D')^(1/2) pdist2_12 = 0.5885

pdist2(X,X)函数的第二行第一列的元素为X的第二行减去第一行,然后根据欧几里得公式d_{st}=\sqrt{(X_{s}-X_{t})\cdot (X_{s}-X_{t})^{T}} 得如下

D=X(2,1:3)-X(1,1:3) D = -0.4183 -0.4139 0.0031 K>> pdist2_21=(D*D')^(1/2) pdist2_21 = 0.5885

其他也是如此!!!

2、pdist2(X,Y)的使用 X = rand(3,3) Y = [X(:,1:2) rand(3,1)] X = 0.2874 0.7624 0.6455 0.5017 0.5761 0.1232 0.7615 0.7477 0.5044 Y = 0.2874 0.7624 0.3473 0.5017 0.5761 0.0921 0.7615 0.7477 0.1478 K>> D=pdist2(X,Y) D = 0.2983 0.6220 0.6875 0.3617 0.0311 0.3124 0.4997 0.5167 0.3565

用同样的方法可得出结果!!!



【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有