Thank you very much for this code. Particularly thanks to John for explaining me a problem I had with the code:
I have tried the following:
in = inhull(tms,tms);
which gave roughly ~319
as John points out:
"those 319 points were almost certainly on the surface of the convex hull.
Try this slight modification of your code instead.
in = inhull(tms,tms,,1.e-13);
See that I've used a tolerance this time. The linear algebra used in the test is done in floating point arithmetic in matlab, as it must be. Without a tolerance, any test done in floating point arithmetic is suspect. By default that tolerance is zero, but this is also why I allowed the user a tolerance at all. "