Octave position of maximum value in column

Philip Massey picture Philip Massey · Oct 5, 2014 · Viewed 36.3k times · Source

I want to find the argmax of the values in a matrix by column, e.g.:

1 2 3    2 3 3
4 5 6 -> 
3 7 8 

I feel like I should just be able to map an argmax/posmax function over the columns, but I don't see a particularly intuitive way to do this in Octave.

Answer

Nishant picture Nishant · Oct 5, 2014

Read max function documentation here

[max_values indices] = max(input);

Example:

input =

1   2   3
4   5   6
3   7   8

[max_values indices] = max(input)
max_values =

4   7   8

indices =

2   3   3