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

8 vues (au cours des 30 derniers jours)
Amulya NV
Amulya NV le 31 Juil 2016
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 :)

Réponse acceptée

the cyclist
the cyclist le 31 Juil 2016
[max_m,idx_m] = max(m,[],3)

Plus de réponses (0)

Catégories

En savoir plus sur Creating and Concatenating Matrices dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by