We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 6f129b8 + 1177f91 commit 0cef02aCopy full SHA for 0cef02a
algorithms/maths/euclidean_distance.m
@@ -0,0 +1,14 @@
1
+% This function takes two n-dimensional vectors as input and calculates the euclidean distance
2
+function distance = euclidean_distance(coordinate_1,coordinate_2)
3
+ if length(coordinate_1) ~= length(coordinate_2)
4
+ disp('Dimensions of vectors do not match!')
5
+ distance = NaN;
6
+ else
7
+ sum = 0;
8
+ for i=1:1:length(coordinate_1)
9
+ difference = (coordinate_2(i)-coordinate_1(i))^2;
10
+ sum = sum + difference;
11
+ end
12
+ distance = sqrt(sum);
13
14
+end
0 commit comments