cubic spline interpolation of a function that yields NaNs when evaluated at some of the grid points.
6 views (last 30 days)
Show older comments
Hi i want to cubic spline interpolate an unknown function defined over a 3 dimensional domain, whose values i know at the gridpoints of some 3D grid. This can conveniently be done with griddedinterpolant, which even allows extrapolation.
Yet my unknown function is not defined on a part of the grid, hence it takes the value NaN at some gridpoints, like:
4 3 2 1
3 2 1 NaN
2 1 NaN NaN
1 NaN NaN NaN
If i now use griddedinterpolant, the interpolant gives NaN, whether inside or outside the boundaries of the grid.
Is there some way to overcome this problem? Is there a way to get a cubic spline interpolation for a function that yields NaNs on some parts of the grid, on which the interpolant is defined?
Any advice is greatly appreciated!
0 Comments
Answers (3)
Image Analyst
on 29 Jun 2013
You're not going to be using coordinates down there anyway - you can't since you don't know what they are - so just set them to anything, such as 1, and do your spline. It doesn't really matter what you do down there. Now if you needed to extrapolate into the nan zone, that's a different question. I might use John DÉrrico's polyfitn() to do that. (See the File Exchange).
0 Comments
See Also
Categories
Find more on Interpolation in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!