Resources

How can I find the index of the largest element of a matrix?

0

Is there a way to efficiently find the index of the largest element in a matrix. For example, if I have a matrix like:

1 3 9
2 4 5
1 3 3

The largest element is the [1, 2] element which is equal to 9.

asked August 30, 2012
admin
27

1 Answer

0
The column index (ci) and the row index (ri) of the largest element  for the matrix ‘x’ can be found like this:
ci = maxindc( maxc( x ) );
ri = maxindc( x[.,ci] );
aptech
227