summaryrefslogtreecommitdiff
path: root/computeTrussCost.m
diff options
context:
space:
mode:
Diffstat (limited to 'computeTrussCost.m')
-rwxr-xr-xcomputeTrussCost.m15
1 files changed, 15 insertions, 0 deletions
diff --git a/computeTrussCost.m b/computeTrussCost.m
new file mode 100755
index 0000000..df7daad
--- /dev/null
+++ b/computeTrussCost.m
@@ -0,0 +1,15 @@
+function [ cost ] = computeTrussCost( C, X, Y )
+ cost = 0;
+ [ j, m ] = size(C);
+ cost = cost + 10*j;
+ for i = 1:m
+ memb = C(:,i);
+ points = [X(memb == 1); Y(memb == 1)];
+ d = dist(points(:,1), points(:,2));
+ cost = cost + d;
+ 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