From 26c2bfa7a7d02286be61a7044d581f31d4f7938f Mon Sep 17 00:00:00 2001 From: Michael Abed Date: Sat, 7 Apr 2012 23:15:25 -0400 Subject: memberdistance and gitignore --- .gitignore | 2 ++ memberDistances.m | 15 +++++++++++++++ weakestMember.m | 2 +- 3 files changed, 18 insertions(+), 1 deletion(-) create mode 100755 .gitignore create mode 100755 memberDistances.m 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 -- cgit v1.2.3-54-g00ecf