MATLAB: Problem using minboundquad function to create a minimum bounding quadrilateral for a given pointset

MATLABminboundquadminimum bounding boxminimum bounding quadrilateral

I had modified one line in the minboundquad.m function to remove the collinear edges in the pointset.
from
edges = convhull(x,y);
to
edges = convhull(x,y,'Simplify',true);
The main code is
load points2.txt
x = points2(:,1);
y = points2(:,2);
[qx,qy] = minboundquad(x,y)
Result I got is below.
This is the output
There is some error I could not find out. Can someone help me solve this?

Best Answer

Modifying the line in minboundquad.m from
if ( A_i < quadarea)
to
if (( A_i < quadarea)&& all(abs([qxi qyi]) < 1e15))
resolves the issue.
Thanks to @Michael Sapper for this suggestion(found in comment section of this toolbox)
Related Question