function [energy]=energy(data,centroids)

energy =0;
	for(i=1:size(data,1))
		[nearest,distance] = findClosest2(centroids, data(i,:));
		centMap(i)=nearest;
		energy = energy + distance;
	end
