MATLAB: How to delete a row if it is smaller than other rows with specific rule

comparisonrow

we say vector a <= b iff a(i)<=b(i) for i=1:size(a).
Now I need to compare rows of a matrix with that rule and delete the biggest row. of course, some rows are incomparable and I need to keep them as well. How can I do this in Matlab? For example for this Matrix
A=[59 98 30 171;
38 56 10 100;
72 100 29 149;
56 96 23 157;
58 97 22 260];
I would be very thankful if you help me. thank you.

Best Answer

See if this is what you want:
A=[59 98 30 171;
38 56 10 100;
72 100 29 149;
56 96 23 157;
58 97 22 260]
[rows, columns] = size(A);
allGreaterThan = false(rows, rows);
for row1 = 1 : rows
for row2 = 1 : rows
if all(A(row1,:) <= A(row2, :))
allGreaterThan(row1, row2) = true;
end
end
end
allGreaterThan
If compares every element of row1 to every element of rows and if all elements in row1 are less than or equal to the corresponding element in row 2, it sets allGreaterThan to true:
allGreaterThan =
5×5 logical array
1 0 0 0 0
1 1 1 1 1
0 0 1 0 0
1 0 0 1 0
0 0 0 0 1