function [center] = centerOfMass2d(M)

% Find the center of mass by summing the x, y, and z values of all of the individuals of an 
% array M and dividing each by the number of elements in M.  M should be in standard (indexed)
% format.

xtotal = 0;
ytotal = 0;


for i = (1:size(M,1))
   xtotal = (xtotal + (M(i,2)));
   ytotal = (ytotal + (M(i,3)));

end


centerX = (xtotal/size(M,1));
centerY = (ytotal/size(M,1));


center = [centerX, centerY];
   