is there an alternative to pdist2 that calculates the distance between a matrices with different column numbers

조회 수: 10 (최근 30일)
I was wondering if there is a built in matlab fucntion that calculates the distance between two arrays that don't have the same column number like in pdist2? For example if matrix A was 102x3 and Matrix B was 3x15, is there a MATLAB function that can do this calculation for me or do I need to use nested for loops?

채택된 답변

Adam Danz
Adam Danz 2020년 9월 4일
편집: Adam Danz 2020년 9월 4일
You just need to transpose B
d = pdist2(A, B');
d(i,j) is the distance between A(i,:) and B(:,j).
  댓글 수: 4
Adam Danz
Adam Danz 2020년 9월 5일
As evidence of what John said, note the indexing I used in my answer to describe d.
d(i,j) is the distance between A(i,:) and B(:,j).

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

제품


릴리스

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by