function newarray=nanize(array,badval)
%function newarray=nanize(array,badval)
% replaces badval (plus or minus 1) with NaN
%
newarray=array;
bad=find(abs(array(:)-badval)<1);
if length(bad)>0
      newarray(bad)=ones(bad/bad(1))*NaN;
end
