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

8 次查看(过去 30 天)
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 CenterFile Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by