필터 지우기
필터 지우기

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 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