function x = l1min(A,b)
%  x = l1min(A,b)
% find x such that norm(A*x-b,1) is minimal

% convert to linear programming problem
%   find xh with Ah*xh<=bh such that f'*xh is minimal
m = size(A,1); n = size(A,2);
I = eye(m);
Ah = [A,-I; -A,-I];
bh = [b;-b];
f = [zeros(n,1); ones(m,1)];
xh = linprog(f,Ah,bh);      % solve linear programming problem
x = xh(1:n);

