You haven't attached any image.
If your image is a single connected blob, regionprops can give you the centre of mass with the centroid property.
If you want the centre of mass for the whole image, regardless of how many blobs are in it, it's fairly trivial:
[x, y] = meshgrid(1:size(img, 2), 1:size(img, 1));
weightedx = x .* img;
weightedy = y .* img;
xcentre = sum(weightedx(:)) / sum(img(:));
ycentre = sum(weightedy(:)) / sum(img(:));