Is this what you want?
x = [-8,-8,-6,0,6,8,8,-8];
y = [10,5,1,0,1,5,10,10];
ship=polyshape(x,y);
figure(1)
clf
hold on
plot(ship)
axis equal
[xc,yc]=centroid(ship);
plot(xc,yc,'xk')
rectangle=polyshape([-12 -12 12 12],[-6 6 6 -6]);
plot(rectangle)
submerged = intersect(rectangle,ship);
[xs,ys] = centroid(submerged);
A = area(submerged);
plot(xs,ys,'ok')
fprintf('Area = %.2f\n',A);
fprintf('Centroid y = %.2f\n',ys)