Find the inear indices of a specific value in a 3d matrix using the positions of a 2d matrix
Mostrar comentarios más antiguos
If I have one 3d matrix A, and one 2d matrix B, how can I find the linear indices of a specific value of A in all its pages, given the position of another value of B?
For instance, if A is a 3x4x4 matrix like:
A(:,:,1)=
0 1 2 0
1 1 0 2
2 2 0 1
A(:,:,2)=
2 0 0 0
0 1 0 2
2 0 1 1
and B is a 3x4 one:
1 1 1 1
2 2 2 2
3 3 3 3
I would like to find all the linear indices of A == 2 when B == 1, such as:
LinInd= [7; 13]
How can I do that?
Respuesta aceptada
Más respuestas (1)
James Tursa
el 15 de Abr. de 2015
Another way:
find(bsxfun(@and,A==2,B==1))
Categorías
Más información sobre Matrices and Arrays 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!