function lmin = minloc(x);

%#realonly
%#inbounds
%# scalar i l

  lmin = [];
  if size(x,1) == 1, x = x'; end
  if size(x,2) ~= 1, return; end

  ll = size(x,1);  l = ll(1);
  if x(1) < x(2), lmin = 1; end
  for i = 2:l-1
    if (x(i-1) > x(i)) & (x(i) < x(i+1)), lmin = [lmin; i]; end
  end
  if x(l-1) > x(l), lmin = [lmin; l]; end
  if isempty(lmin), [kk, lmin]=min(x); end
