The file naninterp.m interpolates NaN's in a vectorfield using two slightly different methods. The calling should look like
[fu,fv]=naninterp(lu,lv,method,mask,x,y);,where method should be 'linear' or 'weighted' and defaults to 'linear' if not specified. This option sorts all spurious vectors based on the number of spurious neighbors to a point and starts by interpolating the vector that have as few neighboring outliers as possible, looping until no NaN's are left. The 'weighted' method uses the file FILLMISS.M to interpolate the outliers (see 'help fillmiss' for some info).
Additionally one can apply a mask to avoid interpolating vectors in a part of the measurement area.
>> [u,v]=naninterp(u,v,'polymask.mat',x,y);,will replace NaN's but leave out areas that have been masked out (using MASK.M) Using the MASK option requires the x and y matrices input along with the velocities, u and v.