Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function Y = k_means_standard(houses, wares)
- W = length(wares);
- H = length(houses);
- Y = houses;
- ware_positions = zeros(2, W);
- for w = 1:W
- ware_positions(:,w) = wares(w).position;
- end
- houses_positions = zeros(2, H);
- for h = 1:H
- houses_positions(:,h) = houses(h).position;
- end
- for h = 1:length(houses)
- dist = distance(ware_positions, repmat(houses_positions(:,h), 1, W));
- [min_dist, index] = min(dist)
- Y(h).closest_ware = index;
- Y(h).closest_ware_distance = min_dist;
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement