-1

Let say I have a 5x5 matrix

A B C D E

1 5 7 2 3
2 1 9 8 5
3 1 2 3 1
4 1 3 4 2
5 2 9 0 1

and I need to find the max of B (which would be 5) and its corresponding value in A (which would be 1), how do I do that?

4

1 に答える 1

0

max は実際には値と場所の両方を返します。M が 5x5 行列の場合:

[mb,i] = max(M(:,2));
ma = M(i,1);

トリックを行う必要があります。

mb があなたに関係ない場合は、

[~,i] = max(M(:,2));
ma = M(i,1);

max の戻り値を破棄します

于 2013-10-23T05:39:13.650 に答える