function  y = minnan(x)
%MAXNAN   Largest component ignoring elements equal to `NaN'. 
%         For vectors, minnan(X) is the largest non-NaN element in X. 
%         For matrices, minnan(X) is a vector containing the minimum 
%         non-NaN element from each column. 
%         [Y,I] = minnan(X) stores the indices of the minimum non-NaN
%         values in vector I.  
%
%         See also MIN, ADDNAN, AVGNAN, CORNAN, MAXNAN, SUMNAN.
% 

%         Ellen R. McGrattan, 7-7-97
%         Revised, 7-7-97, ERM

[m,n]  = size(x);

for j=1:n;
  i      = find(~isnan(x(:,j)));
  if ~isempty(j)
    [y(j),ind(j)] = min(x(i,j));
  else;
    y(j)   = NaN;
    ind(j) = 0;
  end;
end;
