MATLAB: Is there a way to interp3 without interpolating the NaNs

3dextrapolationinterp3?interpolationnanspline

I have a 3D volume with some NaN values in it. I want to interpolate the the volume in order to fill in the NaNs and also extrapolate the volume around it. When I use the 'linear' method it doesn't replace the NaNs and seems to extrapolate them. When I try to use 'spline', I get an error "Insufficient finite values to interpolate." Not sure why.

Best Answer

The fast and reliable https://www.mathworks.com/matlabcentral/fileexchange/4551-inpaint-nans is only documented to work in 2D, but I am told by a recent poster that it works on 3D as well, but that you will need to reshape the result back from 2D to 3D.