MATLAB: How to write name inside polygon

polygonpolyshape

After create a polygon how to write name inside it so you can differeniate between it and the other polygons?

Best Answer

Use the text function.
Try this:
pgon = polyshape([1 3 5 7],[2 6 4 1]);
[xc,yc] = centroid(pgon);
figure
plot(pgon)
axis('equal')
text(xc,yc, sprintf('Polygon with centroid (%.2f, %.2f)', xc, yc), 'HorizontalAlignment','center', 'VerticalAlignment','middle')
producing:
.