Interpolation outside boundaries.

26 ビュー (過去 30 日間)
WILLIAM ZANIN
WILLIAM ZANIN 2020 年 9 月 22 日
コメント済み: Ameer Hamza 2020 年 9 月 22 日
Hi guys,
I'm training myself in data interpolation for a project. With an example set of datas (6 points) I'm able to interpolate data using griddata as you can see in the code below. The question is : is possible to interpolate the surface also in [x,y] that are over x_max and y_max of my points?
As you can see, overall x_max and y_max in my data set is 20, but I created a grid that arrives till 30. Nevertheless the interpolation gives only values under x=20 and y=20.
Thank you.
P = [0 0 0;
20 0 5;
0 20 5 ;
5 5 2;
10 10 10 ;
20 20 10] ;
x = P(:,1) ; y = P(:,2) ; z = P(:,3) ;
ti = 0:1:30;
[XI,YI] = meshgrid(ti,ti);
ZI = (griddata(x,y,z,XI,YI,'cubic'));
surf(XI,YI,ZI), hold
plot3(x,y,z,'ro'), hold off
colorbar

採用された回答

Ameer Hamza
Ameer Hamza 2020 年 9 月 22 日
griddata() does not have the option for extrapolation beyond the data-points. You can use scatteredInterpolant for this; however, it does not have a cubic interpolation option, and the extrapolation is also linear.
P = [0 0 0;
20 0 5;
0 20 5 ;
5 5 2;
10 10 10 ;
20 20 10] ;
x = P(:,1) ; y = P(:,2) ; z = P(:,3) ;
ti = 0:1:30;
[XI, YI] = meshgrid(ti,ti);
model = scatteredInterpolant(x, y, z, 'linear', 'linear');
ZI = model(XI, YI);
surf(XI,YI,ZI), hold
plot3(x,y,z,'ro'), hold off
colorbar
The best way to handle such cases is to have an equation of form z = f(x, y) and then use curve-fitting to estimate the unknown parameter in f(.). Then you can use f(.) to extrapolate the values.
  2 件のコメント
WILLIAM ZANIN
WILLIAM ZANIN 2020 年 9 月 22 日
All clear thank you very much!
Ameer Hamza
Ameer Hamza 2020 年 9 月 22 日
I am glad to be of help!

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

その他の回答 (0 件)

カテゴリ

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

製品

Community Treasure Hunt

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

Start Hunting!

Translated by