MATLAB: Polybool Command Incorrectly Gives Workspace Variables

MATLABnanpolyareapolyboolworkspace

Hello,
I have a series of polygons which overlap and the combined polygons have some holes. I want to calculate the entire area of all the polygons and ignore the holes. I combine the polygons with the polybool command and the union setting and then want to use polyarea to find the area. When I use polyarea, the result is NaN and when I started to trace the problem, I noticed that the arrays which polybool give have a max and min value in the Workspace of NaN. However, if you look at the arrays, there are no NaN's. Has anyone run into this issue? It seems as if I can't use polyarea due to these "ghost" NaN's. If you can think of a better way to find the union area please let me know.
Thanks for any help or suggestions,
Patrick

Best Answer

help polybool
The polygon inputs are NaN-delimited vectors, or cell arrays containing
individual polygonal contours. The result is returned using the same
form as the input.
So if you
[x, y] = polybool('union',xpolypoint(1),ypolypoint(1),xpolypoint(2),ypolypoint(2))
then because those inputs are cells you will get cell outputs, but if you use
[x, y] = polybool('union',xpolypoint{1},ypolypoint{1},xpolypoint{2},ypolypoint{2})
then those inputs are "NaN delimited vectors" that do not happen to have any NaN in them, and the outputs are NaN delimited vectors that do have NaN which mark the end of one vector and the beginning of the next.