Computing Euclidean distance between 2 points
조회 수: 1 (최근 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?
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/986030/image.png)
댓글 수: 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
참고 항목
카테고리
Help Center 및 File Exchange에서 Ordinary Differential Equations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!