Area of polygon
y are vectors of the same length,
polyarea returns the scalar area of the polygon defined by
y are matrices of the same size,
polyarea returns a row vector containing the areas of each
polygon defined by the columnwise pairs in
y are multidimensional arrays, then
polyarea operates along the first dimension whose length is not
equal to 1.
Create a set of points that define a 2-D polygon.
p = linspace(0,2.*pi,9); x = 1.2*cos(p)'; y = 1.2*sin(p)';
Plot the polygon.
plot(x,y); axis equal
Compute the area of the polygon.
a = polyarea(x,y)
a = 4.0729
x-coordinates, specified as a vector, matrix, or multidimensional array.
y-coordinates, specified as a vector, matrix, or multidimensional array.
Dimension to operate along, specified as a positive integer scalar.
The area value returned by
polyarea can depend on the order of
the input points.
This function fully supports GPU arrays. For more information, see Run MATLAB Functions on a GPU (Parallel Computing Toolbox).
This function fully supports distributed arrays. For more information, see Run MATLAB Functions with Distributed Arrays (Parallel Computing Toolbox).