X= pdist2 (A,B, "chebychev")
A and B both are 3000x3 arrays (x,y,z data).
Why is X a 3000x3000 array rather than a 3000x1 array?
This seems to give the right answer though... why?
Z =diag(pdist2 (A,B, "chebychev"));

 채택된 답변

Dave B
Dave B 2021년 11월 15일

0 개 추천

pdist2 is providing all the pairwise distances. It compares row 1 of A with row 1 of B (Z(1,1)), then row 1 of A with row 2 of B (Z(1,2) and Z(2,1)), etc. Along the diagonal are the matching row cases.

댓글 수: 3

Pelajar UM
Pelajar UM 2021년 11월 15일
Thanks, but is there a function that would give only the diagonal values?
I could use the diag function to get this, but when A and B becomes very large, then I run out of memory.
Dave B
Dave B 2021년 11월 15일
편집: Dave B 2021년 11월 15일
Chebyshev distance is the maximum distance across dimensions, right?
a=rand(10);
b=rand(10);
cheby_pdist2=diag(pdist2(a,b,'chebychev'))
cheby_pdist2 = 10×1
0.8386 0.6272 0.8585 0.6400 0.4895 0.8044 0.6681 0.7439 0.8985 0.7146
cheby_daveb=max(abs(a-b),[],2)
cheby_daveb = 10×1
0.8386 0.6272 0.8585 0.6400 0.4895 0.8044 0.6681 0.7439 0.8985 0.7146
Pelajar UM
Pelajar UM 2021년 11월 15일
Right. Thank you so much.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Line Plots에 대해 자세히 알아보기

태그

질문:

2021년 11월 15일

댓글:

2021년 11월 15일

Community Treasure Hunt

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

Start Hunting!

Translated by