MATLAB: How to find the area of a shape

areacross sectional area

My goal for this code is to find the area inside of a polygon, or any shape really. I know that one way of doing it would be to input the coordinate points of the shape's corners, but I'm not sure how to get area from that. I think there should be a way to create an integration field within the original shape and by integrating a cross sectional area like a triangle, inside the original shape, and summing multiple integrations together, I should be able to find the total area, I'm just not sure how to translate these thoughts into code. Could anyone give me a hand?