Re: Assign data point to n-Dimensional grid [message #80691 is a reply to message #80599] |
Tue, 26 June 2012 00:43  |
antar3s86
Messages: 8 Registered: June 2012
|
Junior Member |
|
|
Hi
I have manages to find the nearest neighbor for one parameter using something like that
ii = VALUE_LOCATE(grid, x)
wh = WHERE((grid[ii+1] - x) LT (x-grid[ii]), ct)
if ct GT 0 then ii[wh] = ii[wh]+1
nn = grid(ii)
but I discovered that not all of my parameters are independent. So I split the problem up and located the independent parameters with the procedure above and the dependent ones with a 2-D search using nearestn (http://www.ifa.hawaii.edu/~beaumont/code/nearestn.html). This is a pure coincidence and if I ever have to face a problem with more dependent parameters I will have to think of something else.
Now I face a different problem which I want to describe with an example:
Suppose my grid consists of three parameters, so e.g. gridx = [2,5,10], gridy = [10,40,50], and gridz = [100,101,102]. I need to fit my data point to the first two which can be done with the nearest neighbor method I solved for now. So for two test data points, say, x = [3,11], y = [8,47] they will snap to xs = [2,10], ys = [10,50] which is the 0th and 2nd position in the grid. From that I want to know which z-value and the third grid is assigned to them.
Any ideas how to solve that, meaning how to know at which position the test data points lie in the grid?
|
|
|