user2200676
user2200676

Reputation: 21

Matlab: Find area enclosed by points (x,y)

I've got 8 points that create the outline of an eight-sided polygon in two-dimensional space. I need to find the area enclosed be these points, but how do I do that using matlab?

The eight points (x,y) are contained in the 8x2 matrix B.

B = [ 260 455;
    1187 467;
    1325 605;
    1342 1533;
    1207 1675
    251 1690;
    107 1547;
    116 593];

The polygon is created by drawing straight lines from the point which is row 1 to row 2, then row 2 to row 3 and so on...

Upvotes: 2

Views: 12439

Answers (3)

Alexander Danilin
Alexander Danilin

Reputation: 31

For calculating area and even volume you can use convhull.

Upvotes: 0

fpe
fpe

Reputation: 2750

I would go with trapezoid:

Area = trapz(B(:,1),B(:,2));

Upvotes: 0

3lectrologos
3lectrologos

Reputation: 9642

You can use polyarea:

ar = polyarea(B(:, 1), B(:, 2));

Upvotes: 6

Related Questions