フィルターのクリア

How to find row with maximum value of column?

61 ビュー (過去 30 日間)
Hosup Song
Hosup Song 2016 年 6 月 15 日
回答済み: the cyclist 2016 年 6 月 15 日
I'm currently working with a matrix that is at smallest 1024*11,000. I need to figure out how to find the row with the maximum value at a respective column. For example
A = 1 2 5 6 8 1 2
6 4 8 5 3 2 2
2 1 8 3 2 1 5
for column 1, i would get row 2 as the answer and for column 5, I would get row 1 as the answer. I was wondering if there is an innate function for this or how I would write the code for this. I can't go looking at every entry when I'll have a million entries in a matrix. I need the code to give me the answer in a matrix form like
A1 = 2 2 2 1 1 2 3
Also, how would the code react when there are multiple rows with the same maximum value? Like column 3 of matrix A, when the maximum value is found in both rows 2 and 3. I would really appreciate the help. Thank you!

採用された回答

Azzi Abdelmalek
Azzi Abdelmalek 2016 年 6 月 15 日
編集済み: Azzi Abdelmalek 2016 年 6 月 15 日
[~,jj]=max(A)

その他の回答 (1 件)

the cyclist
the cyclist 2016 年 6 月 15 日
[m,i] = max(A)
m will contain the column maximum.
i will contain the position of the first instance of the maximum.

カテゴリ

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