Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Octave position of maximum value in column

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.

like image 429
Philip Massey Avatar asked Oct 05 '14 17:10

Philip Massey


People also ask

How do you find the maximum element in a column?

To find the max value of a column, use the MAX() aggregate function; it takes as its argument the name of the column for which you want to find the maximum value. If you have not specified any other columns in the SELECT clause, the maximum will be calculated for all records in the table.

How do you find the max position in Matlab?

You can use max() to get the max value. The max function can also return the index of the maximum value in the vector. To get this, assign the result of the call to max to a two element vector instead of just a single variable. Here, 7 is the largest number at the 4th position(index).


1 Answers

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 
like image 69
Nishant Avatar answered Sep 19 '22 21:09

Nishant