Indices of a maximum value in a multidimensional matrix.

48 views (last 30 days)
Hi, I have a multidimensional matrix of size (100,16,4,10) and i want to calculate all the 4 indices of the max value in it? Any help please.

Accepted Answer

Azzi Abdelmalek
Azzi Abdelmalek on 25 Jul 2016
Edited: Azzi Abdelmalek on 25 Jul 2016
a=rand(100,16,4,10); %Example
If the dimension of a is unknown

Sign in to comment.

More Answers (1)

Adam on 25 Jul 2016
Edited: Adam on 25 Jul 2016
[maxVal, idx] = max( myMatrix(:) );
[x, y, z, w] = ind2sub( size( myMatrix ), idx );


Find more on Matrices and Arrays in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by