Using matrix index coming from max function to get values from another matrix
Mostrar comentarios más antiguos
Dear All, I have the following problem:
A = randn(5,5);
B = randn(5,5);
C = randn(5,5);
D = cat(3,A,B,C);
E = randn(5,5,3);
[M,I] = max(D,[],3);
How to use the index matrix I to get respective elements from matrix E ? It means for every combination of i and j I want to take the value of E(i,j,:) whose index is given by the value of I(i,j).
I will be grateful for any comments!
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Linear Algebra en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!