Borrar filtros
Borrar filtros

3D Submatrices extraction by indexing the 3rd dimension

2 visualizaciones (últimos 30 días)
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”.

Respuesta aceptada

Stephen23
Stephen23 el 16 de Oct. de 2023
a_substruct.m1 = a_struct.m(:,:,endsWith(a_struct.i,'1'));
a_substruct.m2 = a_struct.m(:,:,endsWith(a_struct.i,'2'));

Más respuestas (0)

Categorías

Más información sobre Matrix Indexing en Help Center y File Exchange.

Productos


Versión

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by