问题
I have nx4 matrix. I need to find max value and it's index. I use
[mVal,mInd]=max(A,[],2)
When a row contains same value more than once and it is the max value I need to find all indices of the row.
Example: Say A(10,:)
is [-1.2 1.6 1.6 1.6]
I need to return 2,3,4 as indices.
回答1:
Try this:
A(10,:)=[-1.2 1.6 1.6 1.6];
[i,j]=find(A==max(max(A)))
The row indices of the maxima should be in the vector i
, the column indices in j
.
来源:https://stackoverflow.com/questions/29769580/find-max-indices-in-octave