To find out the index of the maximum element of a matrix in Matlab, use:
>> myMat = [1 2 3 4;2 3 4 5;5 6 2 1]
myMat =
1 2 3 4
2 3 4 5
5 6 2 1
>> [row, col] = find(myMat == max(myMat(:)))
row =
3
col =
2
>> myMat(3,2)
ans =
6
>> max(myMat(:))
ans =
6
Reference
How do I find the indices of the maximum (or minimum) value of my matrix? (MathWorks)
沒有留言:
張貼留言