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!