The last question I asked concerned how to bin data by x co-ordinate. The solution was simple and elegant, and I\'m ashamed I didn\'t see it. This question may be harder (
I've never used matlab but from looking at your previous question I suspect your looking for something along the lines of a Kdtree or a variation.
Clarification: Since there seems to be some confusion about this I think an pseudocode example is in order.
// Some of this shamelessly borrowed from the wikipedia article
function kdtree(points, lower_bound, upper_bound) {
// lower_bound and upper_bound are the boundaries of your bucket
if(points is empty) {
return nil
}
// It's a trivial exercise to control the minimum size of a partition as well
else {
// Sort the points list and choose the median element
select median from points.x
node.location = median;
node.left = kdtree(select from points where lower_bound < points.x <= median, lower_bound, median);
node.right = kdtree(select from points where median < points.x <= upper_bound, median, upper_bound);
return node
}
}
kdtree(points, -inf, inf)
// or alternatively
kdtree(points, min(points.x), max(points.x))