%finds the maximum value in each column (like max(abs(in)) but retains sign

function out = maxabs(in);


[NN, N]= size(in); %dimensionality

for n=1:N
    out(n)=in(min(find(abs(in(:,n))==max(abs(in(:,n))))), n);
    if length(find(abs(in(:,n))==max(abs(in(:,n))))) > 1
        display(['WARNING -- multiple entries in column ', num2str(n),' have the same magnitude'])
    end
end


