function [idx,ld] = closest_abs(vec, range)

sz = size(range);

idx = 1;
r = (range(1,:) - vec);
ld = sum(abs(r));

for i=2:sz(1),
  r = (range(i,:) - vec);
  d = sum(abs(r));

  if (d < ld)
    ld = d;
    idx = i;
  end
  if (d == ld)
    [d,i]
  end
end

range(idx,:)
