Hi. My approach would be to first just draw a minimal excess of line: sort the x and y coordinates, take half the difference between each successive point, then draw lines at those points. That will segregate the points into blocks but will of course be an excess of lines. I don't have Matlab, but the Mathematica code below does that. Perhaps you can convert it to Matlab if you wish. Note I can remove the two red lines. Ok, now go through the line arrays and for each line, decide if that line can be removed. I'm not sure how to do that but you may wish to see if you can come up with some type of algorithm to do that.
Code:
nmax = 15;
size = 10;
pointlist = Table[{RandomReal[
{-size, size}], RandomReal[
{-size, size}]}, {nmax}];
plist = Point[pointlist];
xvals = Sort[(#1[[1]] & ) /@ pointlist];
yvals = Sort[(#1[[2]] & ) /@ pointlist];
xnew = Table[(xvals[[i]] + xvals[[i + 1]])/
2, {i, 1, nmax - 1}];
ynew = Table[(yvals[[i]] + yvals[[i + 1]])/
2, {i, 1, nmax - 1}];
xlines = (Line[{{#1, -size},
{#1, size}}] & ) /@ xnew;
ylines = (Line[{{-size, #1},
{size, #1}}] & ) /@ ynew;
Show[Graphics[{xlines, ylines, plist}]]