MATLAB: Is it possible to do multidimensional interpolation on a set of scattered data

build multidimensional arrayinterpnmultidimensional interpolationscattered datascattered interpolation

I’m completely stumped by a seemingly simple problem, and have been for a couple of years. Can any of you smart matlabbers help?
I want to do a multidimensional interpolation of a set of data. So, use interpn, right? (I tried using griddatan and I’ve been waiting for hours while it’s “busy”, trying just one interpolation (not the thousands I need).)
My data are stored in a large 2D matrix. They are not completely ordered, like in the example below. My actual problem has 9 dimensions of independent data, but in the example below, assume the first four columns are independent variables and the fifth column is the dependent variable that I seek an interpolation value for.
To use interpn, I need to supply the function with a multidimensional array – with the number of dimensions matching the number of independent variables (right?). So for this example, I’d need a 4D array. Example:
X1 X2 X3 X4 Y
24 1 8 30 0.73
24 2 9 40 0.04
24 3 9 50 0.18
24 4 10 60 0.88
24 1 11 70 0.18
24 2 12 80 0.94
24 3 8 90 0.36
24 4 9 100 0.58
24 1 10 110 0.86
24 2 10 120 0.49
26 3 10 130 0.03
26 4 11 140 0.90
26 1 12 150 0.03
26 2 8 160 0.12
26 3 9 170 0.85
26 4 10 180 0.35
26 1 11 190 0.51
26 2 12 200 0.05
26 3 12 210 0.49
26 4 13 220 0.45
How do I put them in a 4D array? Ignoring X4 for the moment, and looking at a slice of the array where X3 = 8, we would have this array:
X1\X2 1 2 3 4
24 0.73 0.36
26 0.12
There are empty cells. Is that OK? Otherwise how could we make a multidimensional array from scattered data?
Building that array by hand is impractical with a large array. Is there some automated way to do it? Am I making this harder than it should be? Or is it so hard that I should do something else?
Thanks!!!

Best Answer

After, some consideration I eventually decided to take a different approach. Instead of trying to do a multidimensional interpolation within my large data set, I decided to create neural network models with the data set, and model any points that I need. There are advantages and disadvantages to this approach, but both approaches introduce a small amount of error, and the neural net approach is doable, whereas I never succeeded in the interpolation approach, despite the excellent guidance from Jeremy, Matt J, and Kelley Kearney.
If you are trying to figure out multidimensional interpolation, there are some good points and tools below.