I would like to know if there is a quick way to compute the Euclidean distance of two vectors in Octave. It seems that there is no special function for that, so should I just use the formula with sqrt?
Asked
Active
Viewed 3.5k times
19
Christian Clason
- 12,301
- 3
- 48
- 68
Mouna
- 301
- 1
- 2
- 5
-
This may have been down-voted because this is a basic question you should be able to find the answer for by looking at Octave documentation or doing an appropriate internet search. However, I do see that searching for "octave Euclidean" or "octave Euclidean distance" does not yield useful results nearly as quickly as "octave norm". – Elaine Hale Aug 13 '13 at 20:57
-
suggestion : next time, Google something like "Matlab distance between two vectors". The Mathworks has centralized documentation which is easy to find (there is an official Octave documentation manual which you should find, but it may take a little work to find it). For something this simple, it is probable that a function with the same name in Octave does the same thing. – Stefan Smith Oct 06 '13 at 00:15
-
The stats on this question speak for themselves. – boatcoder Apr 01 '17 at 18:43
3 Answers
3
You can also try distancePoints
http://octave.sourceforge.net/geometry/function/distancePoints.html
THN
- 31
- 1
0
Here is a method to calculate the distance between an array of vectors (X) and a single vector (X(1, :) for example purposes):
distances = sqrt(sum((X - X(1, :)) .^ 2, 2));
Steven C. Howell
- 101
- 2