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

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.

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

1,773

Your Answer

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] );

You must login to post answers.

Have a Specific Question?

Get a real answer from a real person

Need Support?

Get help from our friendly experts.