function in = inside(x, a, b)
% call: in = inside(x, a, b)
% input: 3 scalars x, a, b
% output: 1 (true) if x lies between a and b
%         0 (false) if x does not lie between a and b
% this will work even if x is infinity or NaN
% but first, make sure x is real
in = 0;
if ~isreal(x)   
   return
end
if a <= b
   if x >= a & x <= b
      in = 1;
   end
else
   if x >= b & x <= a
      in = 1;
   end
end
