Permutation function for distance measure
1 回表示 (過去 30 日間)
古いコメントを表示
Hi, i want to get the possible number of distance between k number of coordinate. Assume that we have 2 coordinate (k=2), then the possible distance are (1,2),(2,1). Thus the number of distance for k=2 is 2.
Another example is if k=3, the possible coordinate are (1,2),(1,3),(2,3),(2,1),(3,1),(3,2).
However, i also need to assume that distance between (1,2) and (2,1) is same. Thus if k=2, the possible coordinate is 1 and if k=3, possible coordinate is 3.
I had tried the permutation function in matlab, but it do not suitable , especially when k=3 as below.
Hope the explainantion is clear. Please help to suggest other suitable function or possible code. TQIA
v = [1 2 3];
P = perms(v)
the output:
P =
3 2 1
3 1 2
2 3 1
2 1 3
1 3 2
1 2 3
0 件のコメント
回答 (1 件)
KSSV
2021 年 3 月 11 日
You can get the distances between each pair using pdist. From this you can make decision.
v = [1 2 3];
P = perms(v)
d = pdist(P)
Z = squareform(d)
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Statistics and Machine Learning Toolbox についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!