フィルターのクリア

Pairwise distance between two matrices of 3 columns and 1911 rows.

1 回表示 (過去 30 日間)
Vahid Esmaeili
Vahid Esmaeili 2020 年 7 月 10 日
コメント済み: Vahid Esmaeili 2020 年 7 月 13 日
Hello,
Hello.
I have two questions.
1)- I have two matrices of 3 columns and 1911 rows (matrices have similar dimensions).
In fact, each matrix consists of the data of a moving marker in 3D space. 1st column returns the amount of movement of the marker in the X vector (anteroposterior direction). 2nd column returns the amount of movement of the marker in the Y vector (vertical direction). 3rd column returns the amount of movement of the marker in the Z vector (mediolateral direction). The number of the rows is actually the number of frames that these 3 parameters have been recorded. I have to calculate the distance between each member of matrix A with the corresponding member of matrix B (e.g. 1st member of matrix A (which is the movement of the marker in the anteroposterior direction) with the 1st member of matrix B (which again is the movement of the marker in the anteroposterior direction). sqrt(sum((A - B) .^ 2)) just provides me with 7.6257 37.2261 5.2263 (for each column) while I have to calculate the distance of all 5733 (3*1911) memebrs of matrix A with corresponding member of matrix B.
2)- What I have to do if the number of rows of matrix A is not similar to the number of rows of matrix B?
I appreciate your kind attention to my request.
  4 件のコメント
KSSV
KSSV 2020 年 7 月 10 日
Read about pdist, pdist2.
Vahid Esmaeili
Vahid Esmaeili 2020 年 7 月 11 日
Thank you so much for your answer. It is not easy for me to understand and interpret the complicated output of 'pdist2'. I have to use the data in my thesis.

サインインしてコメントする。

採用された回答

Voss
Voss 2020 年 7 月 11 日
Sounds like you need to do the sum over the second dimension of (A-B).^2; that is, to sum the sqaured differences of positions in each of the X-, Y-, and Z-dimensions in space.
sqrt(sum((A - B) .^ 2,2))
See the documentation for sum for further clarification.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMatrices and Arrays についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by