I have a 4 dimensional array. I can use interpn in Matlab to construct interpolated points between the array values. However, this command only returns the interpolated values at specified points. Is there a way to directly obtain a full function of interpolated points as an output, which I can then evaluate at any point?
Short answer: No.
A slightly longer answer:
There are the workarounds, where you define a function on top of the interpn
, although this will require the recalculation of the interpolation.
e.g.
p = [1 2 3 4 5];
v = [12 16 31 10 6];
f = @(x) interpn(p,v,x,'cubic');
If you want to avoid recalculating the interpolation for new points would require the interpolation to be parametric, which it is not the necessarily the case, e.g. if you use "nearest" as interpolation method. Depending on the type of interpolation you are using (assuming that it is parametric), there might be a different function more suitable.