简体   繁体   English

Matlab / Octave中矩阵两列之间的最大欧几里得距离

[英]Max Euclidean distance between two columns of a matrix in Matlab / Octave

I need to calculate for a program the maximal euclidian distance of vectors that are put together in a matrix A in Octave. 我需要为程序计算在八度音阶中的矩阵A中放在一起的向量的最大欧式距离。

What I have so far: 到目前为止,我有:

for i=1:n 
   for k=i:n+1
      C=A(:,i)-A(:,k);
      maxdiff=max(norm(C),maxdiff);  
   endfor
endfor

This is not working and I don't know why. 这不起作用,我也不知道为什么。 Any help is appreciated! 任何帮助表示赞赏!

You can use pdist from the Statistics Toolbox / Package: 您可以从统计信息工具箱/软件包中使用pdist

A = rand(3,4); % example data
maxdiff = max(pdist(A.'));

Or, manually: 或者,手动:

d = sum(bsxfun(@minus, A, permute(A, [1 3 2])).^2, 1);
maxdiff = sqrt(max(d(:)));

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 两个向量Matlab的两列之间的欧式距离 - Euclidean distance between two columns of two vector Matlab 在matlab中计算两个图像之间的欧几里得距离 - calculating Euclidean distance between two image in matlab 两个向量之间的欧氏距离(单行矩阵) - Euclidean distance between two vectors (single row matrix) 两个站点之间的matlab距离:为什么两个相同点的欧几里得距离是9? - matlab distance between two site: Why is the euclidean distance of two same point 9? Matlab-两个矩阵之间的欧几里得距离 - Matlab - Euclidian distance between two matrix 对矩阵的两列进行排序,同时在 OCTAVE/MATLAB 中保持一列不变 - Sorting two columns of a matrix while keeping one intact in OCTAVE/MATLAB Matlab中给出的欧几里得距离矩阵的邻接矩阵 - Adjacency matrix from Euclidean distance matrix given in matlab 如何仅使用 numpy python 中的矩阵运算来计算两个矩阵之间的欧几里得距离(无循环)? - How to calculate the euclidean distance between two matrices using only matrix operations in numpy python (no for loops)? 在Matlab中矩阵的两个边界之间删除列? - Deleting Columns Between Two Bounds in Matrix in Matlab? 使用Matlab计算输入矩阵与其他两个矩阵之间的最近距离 - Compute the closest distance between an input matrix with two others using matlab
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM