Problem in using interp2

14 次查看(过去 30 天)
IMC
IMC 2021-10-1
评论: IMC 2021-10-1
Hello,
I want to interpolate my latitude longitude values. They are in the form of matrix.
Lat = 406x270;
Lon = 406X270;
I have read docs about it but still can't figure out that how to do interpolation. Vq = interp2(X,Y,V,Xq,Yq). How to use V here? What is meant by 'Xq and Yq contain the coordinates of the query points'?
I have another variable M (2030x1354). So, I want Lat Lon to become:
Lat1 = 2030x1354;
Lon1 = 2030x1354;
So, should I use M instead of V? Then what about Xq and Yq?
After going through some questions I tried using meshgrid for it. But it gave me following error;
Error using repmat
Requested 109620x109620 (44.8GB) array exceeds maximum array size preference. Creation of arrays greater than this limit may take a long time
and cause MATLAB to become unresponsive.
Lat Lon data is attached. Is there anyother way to do interpolation? Thank you.

回答(1 个)

KSSV
KSSV 2021-10-1
编辑:KSSV 2021-10-1
Vq = interp2(X,Y,V,Xq,Yq) ;
In the above V is the value at (X,Y). You need to have that value.It seems you have only Lon and Lat here.
% Demo
[X,Y,Z] = peaks(100) ; % Z is here V
% Do interpolation
x0 = min(X(:)) ; x1 = max(X(:)) ;
y0 = min(Y(:)) ; y1 = max(Y(:)) ;
x = linspace(x0,x1,50) ;
y = linspace(y0,y1,50) ;
[Xq,Yq] = meshgrid(x,y) ;
Zq = interp2(X,Y,Z,Xq,Yq) ;
So get your V i.,e. Z i.e. respective Lon, LAt value.
  11 个评论
KSSV
KSSV 2021-10-1
编辑:KSSV 2021-10-1
Then attach the text file.
IMC
IMC 2021-10-1
I've attached the text file.

请先登录,再进行评论。

Community Treasure Hunt

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

Start Hunting!

Translated by