I need help on finding the max & min values of a 3d array.
28 ビュー (過去 30 日間)
古いコメントを表示
I need help on finding the max & min values of a 3d array.
0 件のコメント
採用された回答
Turlough Hughes
2022 年 2 月 8 日
M = max(A,[],'all')
finds the maximum over all elements of A. This syntax is valid for MATLAB® versions R2018b and later.
From the documentation for min
M = min(A,[],'all')
finds the minimum over all elements of A. This syntax is valid for MATLAB® versions R2018b and later.
0 件のコメント
その他の回答 (1 件)
John D'Errico
2022 年 2 月 8 日
編集済み: John D'Errico
2022 年 2 月 8 日
min and max are not sufficient? For example:
A = randi(1000,[4 3 2])
[maxval,maxind] = max(A,[],'all')
So 954 is the largest value. It occurs where? At the 20th element of A. That is, if the elements of A were strung out in a single vector as they are stored in memory. What subscripts does that correspond to?
[irow,icol,ipage] = ind2sub(size(A),maxind)
4th row. 2nd column, 2nd page.
Min works the same way. Ok, it finds the min, not the max, so not exactly the same way. :)
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Loops and Conditional Statements についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!