Unexpected interpolation result when using scatteredInterpolant or TriScatteredInterp

4 visualizzazioni (ultimi 30 giorni)
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.');

Risposta accettata

Ruben de Bruin
Ruben de Bruin il 7 Apr 2014
Some of the sample-points are very close (machine precision) to eachother. This caused the algorithm to some up with the wrong solution.
Thanks to the people from Mathworks for coming up with the solution via email.
  2 Commenti
Max Rose
Max Rose il 2 Ago 2016
Hi, thanks for contacting the MathWorks People. What did you use in the end to solve the problem with 'linear'-interpolation method?
I think I have a similar problem. But I am not sure whether my problem relates to the method of interpolation (nearest, linear or natural). See my post below.
Will S
Will S il 6 Gen 2020
Modificato: Will S il 6 Gen 2020
I also have this problem and may benefit if the solution to the question posed above that was answer by private email was shared.
In my case, the natrual interpolation method also gives unexpected results.

Accedi per commentare.

Più risposte (2)

Max Rose
Max Rose il 2 Ago 2016
Modificato: Max Rose il 2 Ago 2016
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
j o il 17 Lug 2016
How did you solve it, knowing the mode of failure?

Categorie

Scopri di più su Interpolation in Help Center e File Exchange

Prodotti

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by