Computing Euclidean distance between 2 points
2 views (last 30 days)
Show older comments
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 Comments
Accepted Answer
More Answers (1)
Bruno Luong
on 3 May 2022
Edited: Bruno Luong
on 3 May 2022
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 Comments
See Also
Categories
Find more on Smoothing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!