I have an n-dimensional matrix, funtointerpolate
, and I wish to perform one dimensional interpolation along one of its axes (let's call it axis m
). In Python, interpolate functions such as interp1d
allow one to specify the axis of interpolation. In MATLAB, I cannot see an obvious way to do this using interp1
or any other built-in interpolate functions. Ideally, the function would look something like
interpolatedfun = interp1(funtointerpolate,oldpoints,newpoints,axis = m)
An obvious way to get around this is to loop over all the other axes in funtointerpolate
, but this is rather cumbersome. The motivation for interpolation is that the data in funtointerpolate
is evaluated along a non-uniform grid along the m
axis. I need it to be uniform along m
. Mathematically, suppose I have some tensorial object
A_{ijk}
which is evaluated along a non-uniform grid along the j index. Then, I wish to find a new A
such that the jth index consists of values evaluated on a uniform grid. I know the new uniform grid for the jth index, newpoints
, and the old grid oldpoints
.
You can use the
interpn
function for this purpose:where
V
is your output.(Of course the above is pseudo-code, but it should nicely illustrate the way to solve your problem.)