필터 지우기
필터 지우기

How to compute the Euclidean Distance separately by using pdist function?

조회 수: 5 (최근 30일)
Zhida DENG
Zhida DENG 2017년 11월 19일
댓글: Zhida DENG 2017년 11월 19일
Hi everyone, I got a question when using pdist, it would be so many thanks if you could give me some advice. The pdist(D) usually gives the sum of the distance for the multiple dimension, however, I want to get the distance separately. For example I have a data set S which is a 10*2 matrix , I am using pdist(S(:,1)) and pdist(S(:,2)) to get the distance separately, but this seems very inefficient when the data has many dimensions. Is there any alternative way to achieve this more efficient? Thanks in advance!

답변 (1개)

Image Analyst
Image Analyst 2017년 11월 19일
Use pdist2():
allDistances = pdist2(S, S);
  댓글 수: 1
Zhida DENG
Zhida DENG 2017년 11월 19일
Thank you! but this has same results with squareform(pdist(S)) which are not I wanted. I am seeking the results of S(1,1) - S(2,1) and S (2,1) -S(2,2) separately.

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

Community Treasure Hunt

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

Start Hunting!

Translated by