How to find the row and column of the largest number in an array?

27 ビュー (過去 30 日間)
Prerna Mishra
Prerna Mishra 2022 年 7 月 15 日
回答済み: Chunru 2022 年 7 月 15 日
Hello,
I am new to matlab and I am stuck with this. If I have a matrix A as follows:
4.4347 4.5156
4.462 4.7074
1.111 .985
I want (2,2) for index and 4.707 for value. I am trying the following:
A = [4.4347 4.5156; 4.462 4.7074;1.111 .985 ]
max(A,[],1,'linear')
and
max(A,[],2,'linear')
But I don'g get the desired answer with either of them. Any help pwuld be greatly appreciated!

採用された回答

Chunru
Chunru 2022 年 7 月 15 日
A = [4.4347 4.5156; 4.462 4.7074;1.111 .985 ]
A = 3×2
4.4347 4.5156 4.4620 4.7074 1.1110 0.9850
[Amax, idx] = max(A(:))
Amax = 4.7074
idx = 5
[i, j] = ind2sub(size(A), idx)
i = 2
j = 2

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by