calculate area of boundary of set of 2d-data point

288 views (last 30 days)
Example: I wanna calculate the area of the boundary of set 2d-data as below illustration: I use the code(polyarea) as follows:
k = boundary(x,y);% generate boundary of data points
hold on;
A = polyarea(x,y);%calculate the area of boundary
But the result is: 12 <--- wrong???
How can I fix it?

Accepted Answer

Roger Stafford
Roger Stafford on 7 Feb 2018
I would advise you to "close" the polygon so that the first point is the same as the last point. Otherwise, Matlab may be a bit confused as to how the polygon is defined.
Niklas Kurz
Niklas Kurz on 15 Jul 2020
I like you! You allowed me a second, highly valuable perspective on this issue. Even posted on my date of birth. So it was just destined to be.

Sign in to comment.

More Answers (1)

Mehdi Mosafer
Mehdi Mosafer on 1 Nov 2018
There is a simpler way; just get the 2nd output of the function "boundary:"
[k,A] = boundary(x,y)
Here, "A" is the area.


Find more on Interactive Control and Callbacks in Help Center and File Exchange


Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by