%
% Remove NaN's from an array by substituting the previous
% value (first value must not be NaN)
%
%     yf = fillin( y )
%
% where   yf = filled in time series
%         y  = original time series
%
% Bob Newell, April 1996
%
%---------------------------------------------------------
function yf = fillin( y )
%
if isnan( y(1) ),
  disp( 'error - first value NaN' );
else,
  yf = y(1);
  for i = 2:length(y),
    if isnan( y(i) ),
	  yf = [ yf; yf(i-1) ];
	else,
	  yf = [ yf; y(i) ];
	end;
  end;
end;
return;
%---------------------------------------------------------
