MatLab中squareform的功能

  • Post author:
  • Post category:其他


squareform没有其它功能,只是把一行(或一列)数据整理成方阵。

如:

x=rand(6,2)*100; %产生一组随机数;

d=pdist(x),%计算相互间距离(以行向量表示);

d =

Columns 1 through 6

48.632 31.011 47.256 40.803 46.874 24.729

Columns 7 through 12

41.952 60.944 38.757 23.699 36.698 48.38

Columns 13 through 15

26.169 71.952 80.525

D=squareform(d),%将其整理成方阵(相互间距离):

D =

0 48.632 31.011 47.256 40.803 46.874

48.632 0 24.729 41.952 60.944 38.757

31.011 24.729 0 23.699 36.698 48.38

47.256 41.952 23.699 0 26.169 71.952

40.803 60.944 36.698 26.169 0 80.525

46.874 38.757 48.38 71.952 80.525 0



版权声明:本文为weixin_40546940原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。