Computing Euclidean distance between 2 points
조회 수: 2(최근 30일)
표시 이전 댓글
I found a code computing Euclidean distance as
diff = q - p;
dist = sqrt(diff * diff');
is there any difference from the standard Euclidean distance formula, why transpose is taken?

댓글 수: 0
채택된 답변
추가 답변(1개)
Bruno Luong
2022년 5월 3일
편집: Bruno Luong
2022년 5월 3일
For a row vector d
% sum(d.^2)
is equal to
% d*d'
Example
d=randi(10,1,3)
sum(d.^2)
d*d'
댓글 수: 0
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!