Replace NaN in data with the average of the two nearest data points

Hi All,

I have a 1 D wave with some NaNs(shown as blank in igor). Now I would like to replace these NaNs with the average of the two nearest values. Or replace with the nearest value. 

Is there a simple command, or need to write a function?

Any help would be greatly appreciated.

Cheers,

Mortoo

The Interpolate function can do this for you. Go to Analysis => Interpolate. Then set the Destination Points to the same size as your input. NaNs will then be replaced with the average.