Problem with Interpolation function involving 2 variables

조회 수: 2 (최근 30일)
Sangani Prithvi
Sangani Prithvi 2021년 9월 2일
댓글: Walter Roberson 2021년 9월 2일
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일
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일
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
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.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Interpolation에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by