summaryrefslogtreecommitdiff
path: root/computeTrussCost.m
diff options
context:
space:
mode:
authorMichael Abed <michaelabed@gmail.com>2012-04-07 21:41:05 -0400
committerMichael Abed <michaelabed@gmail.com>2012-04-07 21:41:05 -0400
commit16a2b71748b2b11e24f97da4fce86187152a5aa5 (patch)
tree585e50bb25ff5b4375a0cd3b56d62c474b27948d /computeTrussCost.m
parent4d6abebe7d7ee44053c3cbacf779d664a704f4c6 (diff)
downloadek301-prelim-16a2b71748b2b11e24f97da4fce86187152a5aa5.tar.gz
ek301-prelim-16a2b71748b2b11e24f97da4fce86187152a5aa5.tar.bz2
ek301-prelim-16a2b71748b2b11e24f97da4fce86187152a5aa5.zip
up to date
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