Find the largest element and its location in a 3 dimensional array

5 ビュー (過去 30 日間)
Israa Ahmed
Israa Ahmed 2021 年 8 月 8 日
コメント済み: Walter Roberson 2021 年 8 月 8 日
How to find the largest element and its location in case of a 3 dimensional array in Matlab?

採用された回答

Walter Roberson
Walter Roberson 2021 年 8 月 8 日
編集済み: Walter Roberson 2021 年 8 月 8 日
[largest_value, idx] = max(YourArray, [], 'all', 'linear');
[row, col, page] = ind2sub(size(YourArray), idx);
In older releases you would probably use
[largest_value, idx] = max(YourArray(:));
[row, col, page] = ind2sub(size(YourArray), idx);
  2 件のコメント
Israa Ahmed
Israa Ahmed 2021 年 8 月 8 日
Very Good.
Thank you very much. Both worked well for me.
Note: The second function is "ind2sub" not "ind2sum".
Walter Roberson
Walter Roberson 2021 年 8 月 8 日
Opps, my fingers typed ahead of my brain!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeResizing and Reshaping Matrices についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by