How to find index in multi-dimension matrix

2 vues (au cours des 30 derniers jours)
JZ
JZ le 26 Nov 2021
Say I have a matrix of m x n x l x w (4-D). How may I find the max/min and the corresponding index in 4-D?
I appreciate your help.

Réponse acceptée

Bjorn Gustavsson
Bjorn Gustavsson le 26 Nov 2021
You can do this in 2 simple steps:
[xMax,idx1D] = max(X(:));
[i1,i2,i3,i4] = ind2sub(size(X),idx1D);
HTH

Plus de réponses (0)

Catégories

En savoir plus sur Matrix Indexing dans Help Center et File Exchange

Produits


Version

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by