How to find the maximum value and its index from matrices?

8 ビュー (過去 30 日間)
Amulya NV
Amulya NV 2016 年 7 月 31 日
回答済み: the cyclist 2016 年 7 月 31 日
I have a multi dimensional matrix
m(:,:,1) = [1 2 3 4; 8 -21 23 2; 3 1 3 7; 42 43 12 4]
m(:,:,2) = [23 34 1 5;2 -6 3 -7; 2 -65 2 2; 5 8 52 -1]
m(:,:,3) = [54 1 6 2; 51 -4 1 6; 5 1 7 1; 65 1 57 65]
max = [54 34 6 5; 51 -4 23 6; 5 1 7 7; 65 43 57 65]
index =[3 2 3 2; 3 3 1 3; 3 1 3 1; 3 1 3 3]
max should have the maximum value out of the given matrices. index should indicate which matrix the max value came from.
thanks for your help in advance :)

採用された回答

the cyclist
the cyclist 2016 年 7 月 31 日
[max_m,idx_m] = max(m,[],3)

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by