function [dataOut]=replace_fill_nan(dataIn,fillVal); %replace_fill_nan.m A function to replace fill values in an array with % nans. % % usage: [dataOut]=replace_fill_nan(dataIn,fillVal); % % where: dataOut - output array w/ nan as fill value % dataIn - input array w/ fillVal as fill value % fillVal - fill value for array dataIn % C. Sullivan 01/06/05, coded for quick and easy replacement of netcdf % fill values (1e+35) with nans in arrays extracted % from netcdf files % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Use of this program is described in: % % Sullivan, C.M., Warner, J.C., Martini, M.A., Voulgaris, G., % Work, P.A., Haas, K.A., and Hanes, D.H. (2006) % South Carolina Coastal Erosion Study Data Report for Observations % October 2003 - April 2004., USGS Open-File Report 2005-1429. % % Program written in Matlab v7.1.0 SP3 % Program ran on PC with Windows XP Professional OS. % % "Although this program has been used by the USGS, no warranty, % expressed or implied, is made by the USGS or the United States % Government as to the accuracy and functioning of the program % and related program material nor shall the fact of distribution % constitute any such warranty, and no responsibility is assumed % by the USGS in connection therewith." %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % dataOut=dataIn; if isequal(fillVal,1e35) fills=find(dataIn >= fillVal); else fills=find(dataIn == fillVal); end dataOut(fills)=nan;