function [n1, n2] = findgood( x, xmin, xmax)
%
%  The function [n1, n2] = findgood( x, xmin, xmax) reads the x 
%  vector and finds the indices n1 and n2 between which the 
%  vector x remains between xmin and xmax.
%
% ------------------------------------------------------------------
%  Written by Vassilis Zervakis, while at
%             AINCO-Interocean, Madrid, Spain, in December 1995
%-------------------------------------------------------------------
%
inflag = 0;
nn = length(x);
i = 1;
n1 = 1;
n2 = nn;
while i <= nn,
  if ((x(i) > xmin) & (x(i) < xmax)) & (inflag == 0),
    n1 = i;
    inflag = 1;
  end
  if ((x(i) <= xmin) | (x(i) >= xmax)) & (inflag == 1)
    n2 = i-1;
    inflag = 2;
  end
  i = i+1;
end

