3D Submatrices extraction by indexing the 3rd dimension
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
julian gaviria
le 16 Oct 2023
Commenté : julian gaviria
le 16 Oct 2023
I have a structure array (a_struct) with 2 fields:
a_struct.m= 370x690x109 double
a_struct.i= 109x1 cell. Each cell contains 13 characters, and some of them end with “1” or “2” (e.g., subj01-XXXXt1… subj01-XXXXt2… subj12-XXXXt1, subj12-XXXXt2).
How can I extract two submatrices from “a_struct.m” based on the elements of the third dimension of “a_struct.m (z= 109)” indexed by the last two elements (i.e., “1”, “2”) of the contents of the first dimension of “a_struct.i (x= 109)”? I expect to get something like:
a_substruct.m1= 370x690x30 double
a_substruct.m2= 370x690x40 double
Where the content of “a_substruct.m1” “a_substruct.m2” has been indexed by “a_struct.i”.
0 commentaires
Réponse acceptée
Stephen23
le 16 Oct 2023
a_substruct.m1 = a_struct.m(:,:,endsWith(a_struct.i,'1'));
a_substruct.m2 = a_struct.m(:,:,endsWith(a_struct.i,'2'));
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Matrix Indexing dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!