akalanka
akalanka

Reputation: 607

Find max indices in octave

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.

Upvotes: 1

Views: 2718

Answers (1)

user4729751
user4729751

Reputation:

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.

Upvotes: 6

Related Questions