I have a data-set that has four columns [X Y Z C]. I would like to find all the C values that are in a given sphere centered at [X, Y, Z] with a radius r. What is the best approach to address this problem? Should I use the clusterdata command?
To collect the required C values I'd make a single pass through the data-set (array?) with some quick checks to eliminate most of the points outside the sphere, and then (only for the points that seem eligible) a check of actual radius.
That is, for a candidate point
1) Is x_i between X-r and X+r? 2) If so, is y_i between Y-r and Y+r? 3) If so, is z_i between Z-r and Z+r?
Only if all three tests are true is it possible for the point to be in the desired sphere. For the final test, use precomputed r^2 and ask:
4) Is (x_i - X)^2 + (y_i - Y)^2 + (z_i - Z)^2 less than or equal r^2 ?
If the point passes the final test, include
c_i in your collected C values.