MATLAB: Appending data to scatter(x,y)

scatter

I am n random points in two dimensional space (x,y). I am using scatter(x,y) to visualize them.
Now I want to take the center of mass of these points (x,y) with a formula, and now I want to append them to the scatter(x,y). There are now n+1 points. How do I do this, aside from using 'hold on'?
Your insights would be great

Best Answer

"Center of mass" makes me hesitate a bit on this. Might want to clarify exactly what you mean by that. Do you want to connect the points in order, forming a closed shape, and calculate centroid from that? Or just use averages to find the center of the data points themselves? Or find the center of the outer bounds of the data, directly between min&max?
Assuming the second option above:
x=[0,1,1.5,3,5];
y=[5,3,1.5,1,0];
scatter(x,y);
c=[mean(x),mean(y)];
hold on;
scatter(c(1),c(2));
hold off;
This only appends the center (c) to the plot, not to the data (x,y). To do that,
x=[x c(1)];
y=[y c(2)];