MATLAB: Is ScatteredInterpolant (linear) returning a value far outside of input data

buginterpolationMATLABscatteredinterpolant

So I'm using ScatteredInterpolant to interpolate the values of a measurement on the surface of a helicopter blade. I'm showing it graphically in the figure. The input data is shown with the faint lines at a 45 degree angle. The output is the coloring of the surface. Right in the center is a bright spot. The highest input data value is ~119. The output value at that location is about 2512.
I've attached the data which generated that figure. The function used to generate the Interpolation is:
Interpolant = scatteredInterpolant(inX, inY, inZ, inV,'linear','nearest');
outV = Interpolant(outX, outY, outZ);
For reference, the bad output data point is the 2713 entry in outV. How can I possibly get an output value that is more than an order of magnitude bigger than any input value, when using linear interpolation? Is this a bug?
A quick way to visualize the error:
figure;
plot3(inX, inY, inV, 'o');
hold on
plot3(outX, outY, outV, 'o');

Best Answer

You are making a major error here in what you are trying to do.
plot3(inX,inY,inZ,'bo')
box on
grid on
Now, rotated one way, we see this surface.
Now, rotated slightly differently, we see this:
So you have essentially a nice surface in 2-dimensions. But there is NO information about what happens when you move off that surface. Now, add in the points you are trying to "interpolate".
hold on
plot3(outX,outY,outZ,'r+')
Yep. You are trying to predict values that lie HUGELY away from the 2-manifold of data that you have. Massive extrapolation here.
So, regardless of what scatteredInterpolant did, your results will be complete, meaningless garbage. You don't have three independent variables, comprising a true point cloud. You have a 2-manifold of data.
So what will scatteredInterpolant try to do here? Linear interpolation for any point will involve a tessellation of that domain. It will not be some sort of triangulation of the surface, but a set of tetrahedra spanning, dissecting that domain. At each of those points, you have a value of V that you wish to interpolate.
So scatteredInterpolant uses a tessellation of that domain. Thinking that you have a real point cloud.
tess = delaunayn([inX,inY,inZ]);
whos tess
Name Size Bytes Class Attributes
tess 43112x4 1379584 double
So there are 43112 tetrahedra. Its kind of hard to visualize, since there are so many edges. But the volume looks like this:
Most of those tetrahedra are HUGE things. Spanning across that void where no data exists. scatteredInterpolant has no clue what you did. At any poiint in that domain, it finds the tretrahedron that contains your point. Then it does LINEAR interpolation across that tetrahedron. But remember that most of the tetrahedra are huge things, connecting one "wing" of that surface with the other. (No pun intended with use of the word wing here, on what is essentially airfoil data.)
ScatteredInterpolant just does what it is told, having no idea that when you try to interpolate some point in that volume, it is creating meaningless gibberish as a result. I'm sorry, but you simply cannot use scatteredInterpolant to produce a meaningful result from this data, as you are trying to do.
Do I really need to figure out why you got something mildly strange? Garbage in, garbage out. I guess I could go a bit more deeply into what you have, if you really want it. But it would be a pure exercise in trying to debug code that I don't have, because as I recall, scatteredInterpolant is supplied to us in compiled form.