Interp2 usage with Coordinates

5 次查看(过去 30 天)
Hello,
I have two data sets: a sea surface salinity product for the southern ocean, in a 38 x 1388 x 12 3D Array, in which the data is in 25km x 25km grid (arranged by Lat, Lon, Month). I also have an ocean mixed layer depth product for the Southern Ocean in a 41 x 720 x 12 3D Array, in which data is in a 0.5 degree x 0.5 degree grid (again arranged by lat, lon , month). In order to calculate the salinity budget I have to get these 2 data sets on to the same grid (AKA: the latitudes and longitudes need to match).
This is the code I am using to try and translate the data across onto a grid with the same coordinates as january_clim_sss (sss= sea surface salinity, mld is mixed layer depth)
I have tried this multiple times, switiching around the x ad y values, and each time get the following error notification:
Error using griddedInterpolant
Sample points vector corresponding to grid dimension 1 must contain 720 elements.
Error in interp2>makegriddedinterp (line 226)
F = griddedInterpolant(varargin{:});
Error in interp2 (line 126)
F = makegriddedinterp({X, Y}, V, method,extrap);
Error in GRIDDING (line 1)
january_mld_cor=interp2(lat_sss_so,lon_sss_so,January_Mld,lat_mld_so,lon_mld_so);
Can anyone help me with this issue?
Thanks in advance!!

采纳的回答

Shiva Kalyan Diwakaruni
Hi,
As a workaround, use in-built function 'griddedInterpolant' to achieve the same goal.
As an demonstration, refer to the following code snippet:
>>[X1,Y1] = ndgrid(X,Y);
>>F=griddedInterpolant(X1,Y1,Z,'cubic');
>>[XI,YI]=ndgrid(a,b);
>>Vq= F(XI,YI);
you can follow the below link for more information on griddedInterpolant'
thanks.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Oceanography and Hydrology 的更多信息

产品


版本

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by