poster
2019-11-23, 20:41
I have a problem in which I have to interpolate 4D data d = f(a, b, c) often, because the interpolation happens within an optimisation routine. Now, at first I programmed this using Matlab's interpn (https://nl.mathworks.com/help/matlab/ref/interpn.html) function. However, the program obviously became very slow, because the cubic splines had to be constructed upon each iteration within the optimisation.
I have read about 2D spline interpolation (https://nl.mathworks.com/help/matlab/ref/spline.html) and I am basically looking for its 4D equivalent: pp = spline(a,b,c,d). Also, I found the scatteredInterpolant (https://nl.mathworks.com/help/matlab/ref/scatteredinterpolant.html#bvkmyb8-Method) function (I have a non-uniform grid), but this function only gives me options for 'linear', 'nearest', or 'natural' and not the 'spline' option I'm looking for.
I could imagine that Matlab would have the function that is underneath the interpn function available, but I can't seem to find it. Does anyone know such a function that returns the piecewise polynomial or some other form of a spline function for a 4D interpolant, preferably Matlab-original?
P.s. I have also looked into a workaround; typing edit interpn, I have tried copying the Matlab function interpn, naming it differently and editing it such that it returns F instead of Vq, the interpolating function. However, doing this it says it doesn't recognise the methodandextrapval function, the first nested Matlab built-in it encounters.
更多... (https://stackoverflow.com/questions/59003492/how-do-i-construct-a-piecewise-polynomial-cubic-spline-for-4d-data-in-matlab)
I have read about 2D spline interpolation (https://nl.mathworks.com/help/matlab/ref/spline.html) and I am basically looking for its 4D equivalent: pp = spline(a,b,c,d). Also, I found the scatteredInterpolant (https://nl.mathworks.com/help/matlab/ref/scatteredinterpolant.html#bvkmyb8-Method) function (I have a non-uniform grid), but this function only gives me options for 'linear', 'nearest', or 'natural' and not the 'spline' option I'm looking for.
I could imagine that Matlab would have the function that is underneath the interpn function available, but I can't seem to find it. Does anyone know such a function that returns the piecewise polynomial or some other form of a spline function for a 4D interpolant, preferably Matlab-original?
P.s. I have also looked into a workaround; typing edit interpn, I have tried copying the Matlab function interpn, naming it differently and editing it such that it returns F instead of Vq, the interpolating function. However, doing this it says it doesn't recognise the methodandextrapval function, the first nested Matlab built-in it encounters.
更多... (https://stackoverflow.com/questions/59003492/how-do-i-construct-a-piecewise-polynomial-cubic-spline-for-4d-data-in-matlab)