Reduce the number of vertices in a closed polygon while maintaining the shape and detail as much as possible.
Unlike similar functions, this one will allow you to reduce to a specific number of vertices.
Peter Bone (2020). Polygon simplification (https://www.mathworks.com/matlabcentral/fileexchange/45342-polygon-simplification), MATLAB Central File Exchange. Retrieved .
Significant speed up.
Fixed error referencing non-existing variable.