Hi all,
I am using Matlab to measure the area of the union of multiple polyshapes. I am encountering issues when including polyshapes that are empty, meaning that the XY coordinates of the polyshapes are all equal to 0. The reason why I want to keep these empty polyshapes is that I will use this code structure to read coordinates from an Excel file in which, for some polyshapes, coordinates will be equal to 0.
I would therefore like the union to ignore those empty polyshapes and report the area of the union of the remaining polyshapes. Please see the example below which is giving me problems:
pol1=polyshape([0 0 0 0],[0 0 0 0])pol2=polyshape([0 0 0 0],[0 0 0 0])pol3=polyshape([-442 -442 1742 1742],[-266.5 1917.5 1917.5 -266.5])pol4=polyshape([-992 -992 1192 1192],[-992.5 1191.5 1191.5 -992.5])pol5=polyshape([-717 -717 1467 1467],[-992.5 1191.5 1191.5 -992.5])pol6=polyshape([-442 -442 1742 1742],[-992.5 1191.5 1191.5 -992.5])poly1=[pol1 pol2 pol3 pol4 pol5 pol6]polyout=union(poly1)area_polyout=area(polyout)
The above reports the following result:
area_polyout = 0
If I delete pol1 and pol2 from the script, I obtain the following:
area_polyout = 7556640
Which is what I'm after.
Would anybody know how to implement an IF statement or something similar to ignore polyshapes when empty from the union?
Many thanks,
Emilio
Best Answer