Unexpected interpolation result when using scatteredInterpolant or TriScatteredInterp
Show older comments
I'm usuing scatteredInterpolant to linearly interpolate scattered data. The Z values (samples) in my data-set range from 0.005 to 15.26 and the point that I'm interpolating to is fully enclosed by avaialble points, so interpolation is possible.
I would expect a value of about 0.04, but both scatteredInterpolant and TriScatteredInterp return values of -85.8, which doesn't make sense at all.. Using 'natural' or 'nearest' does produce realistic results.
All required data to reproduce this issue is attached and given below. Any help is greatly appriciated.

top view, blue points are available data, red dot is requested point

same plot in 3d
Code (required .mat file is attached)
close all; clear all; clc;
load('debugData');
% Since we're using linear interpolation, we would expect a result
% between the minimum and maximum of zz
min(zz)
max(zz)
temp = scatteredInterpolant(real(xx),real(yy),real(zz),'linear','none');
% linear interpolation
% no extrapolation
howcanthisbe = temp(rx,ry) % would exepect 0.04 but gives -85
% trying the old method
old = TriScatteredInterp(xx,yy,zz);
oldResult = old(rx,ry) % same result
% top view
figure;
plot(xx,yy,'b.');
hold on;
plot(rx,ry,'r.');
% and 3d
figure;
t = delaunay(xx,yy);
defaultFaceColor = [0.6875 0.8750 0.8984];
trimesh(t,xx,yy, zz, ...
'EdgeColor','b','FaceColor',defaultFaceColor,'FaceAlpha',0.5)
hold on;
scatter3(xx,yy,zz);
hold on;
scatter3(rx,ry,howcanthisbe,'r.');
Accepted Answer
More Answers (2)
I do also observe strange results from scateredInterpolant when there are many sample points which are very close together.
My variables are x, y, z coordinates (3D space) and the respective values for each combination of x,y,z. There is a high density of values scattered around in the center of the 3D space. Passing now all the coordinates to scatteredInterpolant gives a 3D grid with very 'noisy'-like values. The picture below (a plain slice through the center of the 3D space) shows that situation for 'linear' interpolation.

The picture below (a plain slice through the center of the 3D space) shows that situation for 'natural' interpolation.

The picture below (a plain slice through the center of the 3D space) shows that situation for 'nearest' interpolation.

After trying the above three methods of interpolation, I decided to reduce the amount of data. And after doing the interpolation my results looks more like a smooth variation of values as expected. See image below (used a finer grid for this image).

As a comparison I show a slice of the data that makes up the input of the scattered values. See image below.

An assumption: scateredInterpolant can only work on a certain amount of data? For me the amount of data matters because it is dense in the center of the space and sparse in the outer regions far from the center of the space (spherical symmetric data).
Can anyone confirm my observation? Or give a hint on how to solve this problem without sacrificing data?
j o
on 17 Jul 2016
0 votes
How did you solve it, knowing the mode of failure?
Categories
Find more on Interpolation in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!