在八度中查找最大索引 [英] Find max indices in octave

查看:64
本文介绍了在八度中查找最大索引的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有nx4矩阵.我需要找到最大值及其索引.我用 [mVal,mInd]=max(A,[],2) 当一行包含多个相同值且是最大值时,我需要找到该行的所有索引.

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.

例如:说A(10,:)[-1.2 1.6 1.6 1.6],我需要返回2,3,4作为索引.

Example: Say A(10,:) is [-1.2 1.6 1.6 1.6] I need to return 2,3,4 as indices.

推荐答案

尝试一下:

A(10,:)=[-1.2 1.6 1.6 1.6];
[i,j]=find(A==max(max(A)))

最大值的行索引应在向量i中,列索引应在j中.

The row indices of the maxima should be in the vector i, the column indices in j.

这篇关于在八度中查找最大索引的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆