function output_m = remove_negative_element(input_matrix)
    temp = input_matrix;
    while(1)
        [m n] = size(temp);
        ok=1;
        for i=1:m
            for j=1:n
                if (temp(i, j) < 0 & i ~= j)
                    x=i;y=j;
                    ok=0;
                    break;
                end                
            end
            if (ok == 0)
                break;
            end
        end
        if (ok == 1)
            break
        end
        temp(x, :) = [];
        temp(:, y) = [];
    end
    output_m = temp;