Interp2 usage with Coordinates

9 ビュー (過去 30 日間)
Tim Holgate
Tim Holgate 2021 年 2 月 8 日
回答済み: Shiva Kalyan Diwakaruni 2021 年 2 月 11 日
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
Shiva Kalyan Diwakaruni 2021 年 2 月 11 日
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 Center および File ExchangeOceanography and Hydrology についてさらに検索

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by