MATLAB: 2D grid interpolation problem

interpolationsurface

Hello,
I'm having trouble with 2d interpolation using interp2.
I have a grid of data, 200×200. I've plotted the surface and there are some values missing from my data set. I need to calculate the volume beneath this surface and to do that i need to get rid of any NaN values so the trapz function will work.
I've tried using interp2 but i get the error "Interpolation requires at least two sample points in each dimension."
There is no row or column in my data matrix which is composed entirely of NaN. Is it an issue if there are several NaN values in a row (does it interpolate between values 1 cell apart)?
Any help greatly appriciated, this is driving me nuts!
Many thanks,
Luke

Best Answer

Look in the File Exchange for John D'Errico's inpaint_nans