Problem with Interpolation function involving 2 variables

Hi,
I've tried to use the interp2 function to interpolate 'Zq' coordinates from the raw 'X,Y,Z' data attached in the file here. Interpolation is carried for Xq = -60:60 and Yq = -160:160.
I'm getting an error of this kind when I run the program.
" Error using griddedInterpolant
The grid vectors must be strictly monotonically increasing"
Is there a way to find the interpolation for such data?

 採用された回答

Walter Roberson
Walter Roberson 2021 年 9 月 2 日

0 投票

filename = 'https://www.mathworks.com/matlabcentral/answers/uploaded_files/727494/xyz.xlsx';
T = readtable(filename);
F = scatteredInterpolant(T.X, T.Y, T.Z);
Xq = -60:60;
Yq = -160:160;
[XQ, YQ] = meshgrid(Xq, Yq);
ZQ = F(XQ, YQ);
surf(XQ, YQ, ZQ, 'edgecolor', 'none');
xlabel('x'); ylabel('y'); zlabel('z')

その他の回答 (1 件)

KSSV
KSSV 2021 年 9 月 2 日

0 投票

T = readtable('xyz.xlsx') ;
x = T.X ; y = T.Y ; z = T.Z;
Xq = -60:60 ;
Yq = -160:160. ;
[Xq,Yq] = meshgrid(Xq,Yq) ;
Zq = griddata(x,y,z,Xq,Yq) ;

3 件のコメント

Sangani Prithvi
Sangani Prithvi 2021 年 9 月 2 日
Thanks for the answer.
I'm getting few NaN values in Zq matrix.
KSSV
KSSV 2021 年 9 月 2 日
You will get only where the points lie outside the give data.
Walter Roberson
Walter Roberson 2021 年 9 月 2 日
You might want to set an extrapolation method.

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

カテゴリ

ヘルプ センター および File ExchangeInterpolation についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by