Find values of a specific page of a 3d matrix at specific positions
Afficher commentaires plus anciens
I have two matrices (A and B). A is a 2D matrix (3x3) which defins some zones (1, 2, and 3).
A=
1 1 1
2 2 2
3 3 3
B is a 3D matrix (3x3x2) like:
B(:,:,1)
1 2 1
2 1 2
1 1 2
B(:,:,2)
2 2 2
1 1 2
2 2 1
I would like to find the indices (rows, and columns, or linear indices) of B, when B equals (e.g.) 2 only in (e.g.) page 1, and only in (e.g.) zone 2.
I tried this, but it didn't do the job:
[rA_2 cA_2]= find(A==2);
[r0B_2 c0B_2]= ind2sub(size(B),find(B(rA_2,cA_2,1)==2);
I seem not to find a solution for what I thought to be a quite simple task.
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Matrix Indexing dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!