MATLAB: How to interpolate with function interp2 with longitude and latitudes coordinates

interp2interpolation

Hi!
I have this:
X= [-97.3750 -97.1250]
Y= [22.3750 22.3750]
lat=[22.3623 22.3623]
lon=[-97.3500 -97.3500]
V=[0.1085 .0693]
Vq= interp2(X,Y,V,lon,lat,'lineal');
Sintax Error:
Error using griddedInterpolant
Interpolation requires at least two sample points in each dimension.
Error in interp2>makegriddedinterp (line 228)
F = griddedInterpolant(varargin{:});
Error in interp2 (line 128)
F = makegriddedinterp({X, Y}, V, method,extrap);
**Why can't I interpolate? Thanks!!

Best Answer

Error using griddedInterpolant
Interpolation requires at least two sample points in each dimension.
Your X and Y matrix have only 2 values (in one dimension)
X= [-97.3750 -97.1250];
Y= [22.3750 22.3750];
[X1,Y1] = meshgrid(X,Y); % now they are 2D matrices (2 values in each dimension)
lat=[22.3623 22.3623];
lon=[-97.3500 -97.3500];
V=[0.1085 .0693]; % has to be 2D matrix also (the same size as X or Y)
Vq= interp2(X,Y,V,lon,lat,'lineal');