Info

この質問は閉じられています。 編集または回答するには再度開いてください。

Producing a matrix from particular calculations from 3D cell array (of vectors)

1 回表示 (過去 30 日間)
Hayao
Hayao 2018 年 4 月 12 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
Dear all, I was wondering if there is a way to produce a matrix consisting of distance between all possible combination of two vectors defined in 3D cell array of vectors.
For example, suppose I have a 3x3x3 cell array, where each cell contains a vector with x, y, z coordinates. I want to make a matrix containing Euclidean distance between every single possible combination of vectors defined in 3x3x3 including its own (=27 vectors), which the same vector pair is going to produce zero. So in the end, we should get 27x27 matrix with zero for diagonal elements.
What I thought of was using "for i = 1:3" commands to index particular vector, and use them over and over again to define the 27x27 matrix but that seems like a very inefficient thing to do.
Is there a more efficient way to do this?
Thank you.
  2 件のコメント
KSSV
KSSV 2018 年 4 月 12 日
Read about pdist2
Hayao
Hayao 2018 年 4 月 12 日
編集済み: Hayao 2018 年 4 月 13 日
Oh! That's a cool command. Thank you very much!

回答 (0 件)

この質問は閉じられています。

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by