MATLAB: How to get the area of each polygon of a voronoi diagram

delauneyvoronoi

I need to find areas of all the polygons inside a voronoi diagram and then alot diffrent properties based on different areas. I know the co-ordiantes of all the polygons but cannot distinguish between the ones forming the specific polygon

Best Answer

x = rand(10,1) ; y = rand(10,1) ;
[v,c] = voronoin([x y]) ;
figure
hold on
voronoi(x,y)
A = zeros(length(c),1) ;
for i = 1:length(c)
v1 = v(c{i},1) ;
v2 = v(c{i},2) ;
patch(v1,v2,rand(1,3))
A(i) = polyarea(v1,v2) ;
end