MATLAB: Interpolating one dimension in 4-th dimensional matrix

4-th dimensiondepthinterpolationmatrix

Hi Matlab users.
I have a matrix which is like that (132,238,35,6) this is for longitude, latitude, depth and time. And I want to interpolate the depth so I will have 70 instead of 35. The problem is that I don't know how to properly do that because if I try to call the depth like that: (1,1,:,1) I will have only the one corresponding first longitude and first latitude, not the entire depth. Also If I call like that: (:,:,35,:) the interpolation function don't work. Is there any way to interpolate a 4-th dimensional matrix so I will obtain 70 depths instead of 35?
Thank you,

Best Answer

  • interpn(Longs,Lats,Depths,Times,TheMatrix,Longs,Lats,NewDepths,Times)
    Note: if you do not want to extrapolate the most obvious new depths would include the ones half-way between the old depths, which would lead to 69 output depths, not 70.