Finding largest values in matrix

I would like to find the 10 largest values in a 90x90 matrix, and their indices. Any suggestions? Thanks, Yaniv

 採用された回答

Ced
Ced 2016 年 4 月 10 日
編集済み: Ced 2016 年 4 月 10 日

5 投票

A = randn(90);
Nmax = 10; % get Nmax biggest entries
[ Avec, Ind ] = sort(A(:),1,'descend');
max_values = Avec(1:Nmax);
[ ind_row, ind_col ] = ind2sub(size(A),Ind(1:Nmax)); % fetch indices
You can of course also use a while loop and pick out one value at a time.

1 件のコメント

Yaniv
Yaniv 2016 年 4 月 10 日
Looks great, exactly what I needed. Thanks.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeApp Building についてさらに検索

タグ

質問済み:

2016 年 4 月 10 日

コメント済み:

2016 年 4 月 10 日

Community Treasure Hunt

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

Start Hunting!

Translated by