Find max indices in octave

余生颓废 提交于 2019-12-24 07:30:07

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!