Find the row/column with the lowest maxima

Viewed 85

Consider the matrix below:

A = randi([0 100], 5, 7)

62   59   20   42   49   41   83
37   34   13   65   82   47   24
93   33   19   93   30   37   20
42   49   74   96   26   41   21
14   85   14   90   77    4   96

first I want to find the maxima of each row and the column index:

   83    7
   82    5
   93    1
   96    4
   96    7

then I need to find the row with the lowest maxima:

82 5 2

so far, I have implemented this:

close all;
clear all;
clc;

A = randi([0 100], 5, 7);

[M1, I1] = max(A, [], 2);

[M1, I1]

[M2, I2] = min(M1);

[M2, I1(I2), I2]

Though it feels like a workaround, I wondered if there is a more canonical way to do this? Maybe a built-in function or min/max syntax for this specific purpose?

P.S. Shared this question also on the MATLAB Discord channel.

1 Answers

What about this with find?

M = min(max(A,[],2));
[i,j] = find(A == M);
[M,j,i]
Related