TriScatteredInterp doesn't extrapolate outside scattered data points

1 回表示 (過去 30 日間)
Abdelmoumen Bacetti
Abdelmoumen Bacetti 2015 年 11 月 16 日
回答済み: Abdelmoumen Bacetti 2015 年 11 月 18 日
hello everybody
I wonder why Mathworks considers TriScatteredInterp(x,y,z) as an extrapolation function while it only interpolates inside the area defined by "x,y" scattered points and it doesn't calculate outside that area.
Am I doing something wrong, here is the code:
pos = [ 401.5 387.5 659.5 523.5 349.0 509.5;...
304.0 305.0 405.5 205.0 483.5 229.5];
z1 = rand(1,6);
F1 = TriScatteredInterp(pos(1,:)',pos(2,:)',z1');
gx = 300:5:700;
gy = 200:5:500;
[qx,qy] = meshgrid(gx,gy);
z_1 = F1(qx,qy);

採用された回答

John D'Errico
John D'Errico 2015 年 11 月 16 日
編集済み: John D'Errico 2015 年 11 月 16 日
These tools use a triangulation of your data. They only are able to interpolate if your data is inside one of the triangles. And since a delaunay triangulation only extends out to the convex hull of your data, they do not extrapolate. Anyway, extrapolation is dangerous business.
Note that scatteredInterpolant can apparently extrapolate linearly based on the gradients at the edges, but that extrapolation will be poor in general. Do not trust it for far outside of your data. If you do not have the current release, then TriScatteredInterp does not support extrapolation at all.
Here is the help for scatteredInterpolant for extrapolation. Note that TriScatteredInterp never claims to extrapolate that I see anywhere in the help.
F = scatteredInterpolant (..., METHOD, EXTRAPOLATIONMETHOD) supports the
selection of an extrapolation method to be used outside the convex hull.
Where EXTRAPOLATIONMETHOD is one of the following:
'nearest' - Evaluates to the value of the nearest neighbor on the
boundary (default for METHOD ='nearest')
'linear' - Performs linear extrapolation based on boundary gradients
(default for METHOD = 'linear' and METHOD='natural')
'none' - Queries outside the convex hull will return NaN
  1 件のコメント
Abdelmoumen Bacetti
Abdelmoumen Bacetti 2015 年 11 月 16 日
Ohh, actually i won't trust any extrapolation unless I can cross validate it.
All I want, is to have values everywhere over my grid, and only the part inside the hull interests me.
Thanks anyway, and I guess i should use the trial version of R2015 to see it working.

サインインしてコメントする。

その他の回答 (2 件)

Walter Roberson
Walter Roberson 2015 年 11 月 16 日
The link you posted refers only to scatteredInterpolant(), not to TriScatteredInterp() . TriScatteredInterp() is still present in MATLAB but the recommendation is to replace it with calls to scatteredInterpolant()
  1 件のコメント
Abdelmoumen Bacetti
Abdelmoumen Bacetti 2015 年 11 月 16 日
編集済み: Abdelmoumen Bacetti 2015 年 11 月 16 日
scatteredInterpolant() seems doesn't exist in R2012.
I can't test if it does extrapolation in a grid larger than the data points.

サインインしてコメントする。


Abdelmoumen Bacetti
Abdelmoumen Bacetti 2015 年 11 月 18 日
Hello
I found a toolbox that does an amazing job
Thanks for your contributions, and I hope you find this toolbox useful as I did.

カテゴリ

Help Center および File ExchangeBounding Regions についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by