diff options
-rwxr-xr-x | .gitignore | 2 | ||||
-rwxr-xr-x | memberDistances.m | 15 | ||||
-rwxr-xr-x | weakestMember.m | 2 |
3 files changed, 18 insertions, 1 deletions
diff --git a/.gitignore b/.gitignore new file mode 100755 index 0000000..e89c489 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ + +*.*~ diff --git a/memberDistances.m b/memberDistances.m new file mode 100755 index 0000000..bd51f3d --- /dev/null +++ b/memberDistances.m @@ -0,0 +1,15 @@ +function [ D ] = memberDistances(C, X, Y) + [ ~, m] = size(C); + D = zeros(m,1); + for i = 1:m + memb = C(:,i); + points = [X(memb == 1); Y(memb == 1)]; + D(i) = dist(points(:,1), points(:,2)); + end + +end + + +function [ d ] = dist(p1, p2) + d = sqrt((p1(1)-p2(1))^2+(p1(2)-p2(2))^2); +end
\ No newline at end of file diff --git a/weakestMember.m b/weakestMember.m index 6b67d64..7b95542 100755 --- a/weakestMember.m +++ b/weakestMember.m @@ -5,7 +5,7 @@ function [ idx ] = weakestMember(D, T) p(p > 0) = 0; a = 1:length(D); - [~,i] = max(abs(p)); + [~,i ] = max(abs(p)); idx = a(i); end |