Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
Drexel University or The Math Forum.



Quick way
Posted:
Jul 26, 2013 10:48 PM


You can use logical operators with the find command. For example, if we have a matrix called matrix, as follows:
matrix = [1 6 8;... 3 5 2;... 2 2 10];
and we want to find the indices corresponding to the maximum element in this matrix, we can simply use a condition like the following:
[ i_index j_index ] = find(matrix >= max(max(matrix))); % This is a oneliner.
In the above case, this will yield the matrix index pair [ i_index j_index] = [3,3], corresponding to the maximum



